Libraries and settings

1. Import and format carbon chemistry data

Seasonality

  • Winter: Jan-Mar

  • Spring: Apr-Jun

  • Summer: Jul-Sep

  • Fall: Oct-Dec

  • Wet: May - October

  • Dry: November - April

2. Check data available

2.1 Locations (all samples)

Figure Supp: Map of the sites where individual samples were collected

Notes: * Check location of individual SiteIDs

2.2 Average GPS point location

Flag samples with coordinates that seem off from the permanent station

# Coordinates<-select(FLK.data, "CTDID", "Latitude", "Longitude", "SiteID")
# Coordinates<-join(Coordinates, WS.GPS.Sites, 
#                  type = "left", by="SiteID")
# Coordinates$Lat_diff <- abs(Coordinates$Latitude-Coordinates$Lat)
# Coordinates$Lon_diff <- abs(Coordinates$Longitude-Coordinates$Lon)
# Check.coordinates1 <- Coordinates[(Coordinates$Lat_diff>0.02), ]
# Check.coordinates2 <- Coordinates[(Coordinates$Lon_diff>0.02), ]
# Check.coordinates <- rbind(Check.coordinates1, Check.coordinates2)
# Check.coordinates <- unique(Check.coordinates)
# #write.csv(Check.coordinates, "FLK_results/2_WrongGPS_points.csv", row.names=F)

- Figure 1: Stations

Figure 1: Location of the permanent sampling stations along the Florida Reef Tract. The black boxes delimitate the biogeographical regions. The color of the stations represents their position along the shelf.

2.3 Number of samples

By zone and location

Sub_region Inshore Mid channel Offshore Oceanic
BB 83 75 82
UK 105 70 110 36
MK 124 126 127 78
LK 133 136 168 85

By year and sub_region

Samples collected each year
Sub_region 2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021
BB 4 11 3 6 30 36 30 35 24 24 37
UK 7 15 3 8 45 51 42 44 30 31 45
MK 15 39 9 11 55 66 53 56 43 44 64
LK 18 51 9 11 58 72 59 76 53 45 70

By climatological season and region

Samples collected in each season
Sub_region Fall Spring Winter Summer
LK 149 133 123 117
MK 132 119 95 109
UK 88 81 72 80
BB 68 60 52 60

By Month-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Months
38 37 19 6 35 January
16 22 37 February
24 2 38 35 33 March
23 38 15 35 37 April
38 16 28 May
20 24 38 38 35 8 June
37 38 17 36 25 July
19 38 34 10 August
38 38 36 September
28 38 18 38 36 October
37 35 37 November
25 36 37 37 35 December

By Season-year

Samples collected by year-month
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 Season
24 16 24 76 72 52 6 35 37 Winter
20 47 76 38 38 66 35 73 Spring
75 76 36 38 72 34 35 Summer
53 36 37 35 38 55 37 75 71 Fall

By Month-region

Samples collected by month-location
Sub_region Zone Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
BB Inshore 7 4 7 9 4 8 10 4 6 8 6 10
BB Mid channel 7 3 6 9 4 5 10 4 6 7 6 8
BB Offshore 7 4 7 9 4 8 10 4 6 8 6 9
UK Inshore 10 4 9 13 6 8 13 6 7 9 9 11
UK Mid channel 7 2 7 5 3 9 9 3 6 6 5 8
UK Offshore 12 3 9 11 5 12 14 5 9 11 8 11
UK Oceanic 3 2 4 3 1 5 4 1 3 4 2 4
MK Inshore 9 6 9 12 8 15 12 8 9 13 9 14
MK Mid channel 9 7 11 12 8 13 13 8 9 13 9 14
MK Offshore 10 6 11 13 7 13 13 8 9 13 9 15
MK Oceanic 6 4 7 6 4 8 8 6 6 8 5 10
LK Inshore 11 8 12 12 7 16 9 10 9 15 9 15
LK Mid channel 12 9 12 12 7 15 10 11 9 15 9 15
LK Offshore 18 7 13 14 10 18 13 15 12 19 12 17
LK Oceanic 7 6 8 8 4 10 5 8 6 9 5 9

Per station during all sampling time

Samples collected in SiteIDs
2010 2011 2012 2014 2015 2016 2017 2018 2019 2020 2021 SiteID Sub_region Zone
2 5 1 1 5 6 5 6 4 4 6 1 BB Inshore
2 5 1 1 5 6 5 6 4 4 6 3 BB Offshore
1 3 1 5 6 5 4 2 3 4 4 UK Inshore
1 3 1 1 5 6 5 4 2 3 4 5 UK Inshore
2 2 1 1 5 5 4 4 3 3 4 5.5 UK Mid channel
2 3 1 5 5 4 4 3 3 5 6 UK Offshore
1 4 1 1 5 5 4 4 3 3 5 6.5 UK Oceanic
2 4 1 1 5 6 5 5 4 4 5 10 MK Inshore
1 3 1 1 5 6 5 4 4 4 6 13 MK Inshore
2 5 1 5 6 3 6 4 4 6 7 MK Inshore
2 3 1 1 5 6 5 5 4 4 6 11 MK Mid channel
1 2 1 1 5 6 5 5 4 4 6 14 MK Mid channel
2 4 1 1 5 6 5 6 4 4 6 8 MK Mid channel
1 4 1 1 5 6 5 6 4 4 6 12 MK Offshore
2 5 1 5 6 5 6 4 4 6 9 MK Offshore
2 4 1 1 5 6 5 4 3 4 5 9.5 MK Oceanic
2 5 1 1 5 6 5 6 4 3 5 16 LK Inshore
2 5 1 5 6 4 6 4 4 6 19 LK Inshore
2 5 1 1 5 6 5 7 5 4 6 24 LK Inshore
2 5 1 1 5 6 5 7 4 4 5 17 LK Mid channel
2 5 1 1 5 6 5 6 4 4 6 20 LK Mid channel
1 5 1 1 5 6 5 7 5 4 6 23 LK Mid channel
2 5 1 1 5 6 5 7 4 4 6 18 LK Offshore
1 4 1 5 6 5 5 4 4 6 21LK LK Offshore
1 2 1 1 5 6 5 7 5 4 6 22 LK Offshore
2 5 1 1 4 6 5 5 4 3 6 21.5 LK Oceanic
1 5 1 1 4 6 5 6 5 3 6 22.5 LK Oceanic
1 1 1 5 6 5 6 4 4 6 2 BB Mid channel
3 1 1 5 6 5 5 4 4 6 15 MK Offshore
2 1 1 5 6 5 4 4 4 6 15.5 MK Oceanic
1 5 6 5 6 4 4 7 EK_IN BB Inshore
1 5 6 5 5 4 4 6 EK_MID BB Mid channel
1 5 6 5 6 4 4 6 EK_OFF BB Offshore
1 5 6 5 6 4 4 5 UK_IN UK Inshore
1 5 6 5 5 4 4 6 UK_MID UK Mid channel
1 5 6 5 6 4 4 6 UK_OFF UK Offshore
5 6 5 7 5 4 6 MR UK Offshore
5 6 5 7 5 4 6 WS LK Offshore

Remove extreme events?

# Label and filter extreme events
  FLK.data$Extreme<-as.factor(FLK.data$Extreme)
  summary(FLK.data$Extreme)
## ColdMortality    LowSalinty        Normal 
##            24            28          1486
  FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

3. TA and DIC salinity normalization

Salinity standardizations

  1. Uses salinity Bottle first, if not available, uses salinity from CTD
#MeanSalinity<-mean(FLK.data[FLK.data$Zone=="Oceanic",]$BestSalinity)
MeanSalinity<-mean(FLK.data$BestSalinity)
sdSalinity<-sd(FLK.data$BestSalinity)

Sal<-paste("Mean salinity = ", round(MeanSalinity, digits=3),
           "(", round(sdSalinity, digits=3), "sd)")
Sal
## [1] "Mean salinity =  35.998 ( 0.796 sd)"
# TA_Sal<- ggplot(FLK.data) + MyTheme+
#   geom_point(aes (BestSalinity, TA_umol_kg, fill=Season), 
#              alpha=0.5, shape=21, size=1)+
#   geom_smooth(aes(BestSalinity, TA_umol_kg), 
#               linetype=2, method = "lm", color="black")
# 
# ggExtra::ggMarginal(
#   p = TA_Sal,
#   type = 'boxplot',
#   margins = 'both',
#   size = 5,
#   colour = 'black',
#   fill = 'gray'
# )
# 
# TA_Sal + facet_wrap(~Zone)
# TA_Sal+ facet_grid(Zone~Season)
# #TA_Sal+ facet_grid(Zone~Precipitation)
# 
# DIC_Sal<- ggplot(FLK.data) + MyTheme+
#   geom_point(aes (BestSalinity, DIC_umol_kg, fill=Season), 
#              alpha=0.5, shape=21, size=1)+
#   geom_smooth(aes(BestSalinity, DIC_umol_kg), 
#               linetype=2, method = "lm", color="black")
#   
# ggExtra::ggMarginal(
#   p = DIC_Sal,
#   type = 'boxplot',
#   margins = 'both',
#   size = 5,
#   colour = 'black',
#   fill = 'gray'
# )
# 
# DIC_Sal + facet_wrap(~Zone)
# DIC_Sal+ facet_grid(Zone~Season)
  1. Calculate TA intercepts

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

  • Use ordinary least squares (OLS)?

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1483   r = -0.2150909   r-square = 0.04626411 
## Parametric P-values:   2-tailed = 5.554604e-17    1-tailed = 2.777302e-17 
## Angle between the two OLS regression lines = 2.960342 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3029.034  -18.44009       -86.89591                NA
## 2     MA 16727.365 -398.53141       -89.85623                NA
## 3    SMA  5454.193  -85.73162       -89.33171                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2875.203        3182.866  -22.70767   -14.17252
## 2     MA      14028.065       21052.254 -518.53531  -323.63321
## 3    SMA       5304.217        5611.820  -90.10534   -81.57020
## 
## Eigenvalues: 3689.572 0.4787585 
## 
## H statistic used for computing C.I. of MA: 3.372132e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = TA_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 190   r = 0.3439909   r-square = 0.1183298 
## Parametric P-values:   2-tailed = 1.1773e-06    1-tailed = 5.886499e-07 
## Angle between the two OLS regression lines = 6.931929 degrees
## 
## Regression results
##   Method Intercept    Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS 2120.6326  7.23549        82.13114                NA
## 2     MA  185.1964 61.02501        89.06119                NA
## 3    SMA 1624.1409 21.03396        87.27808                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       2018.377        2222.888   4.393988    10.07699
## 2     MA      -1234.572         804.417  43.815670   100.48313
## 3    SMA       1515.024        1719.508  18.383517    24.06652
## 
## Eigenvalues: 156.5575 0.3118211 
## 
## H statistic used for computing C.I. of MA: 4.139149e-05

  1. Calculate DIC intercepts

All data

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered)
## 
## n = 1476   r = -0.3875632   r-square = 0.1502053 
## Parametric P-values:   2-tailed = 4.286177e-54    1-tailed = 2.143089e-54 
## Angle between the two OLS regression lines = 1.282267 degrees
## 
## Regression results
##   Method Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  3404.831  -37.96124       -88.49103                NA
## 2     MA 11143.923 -252.70667       -89.77327                NA
## 3    SMA  5566.678  -97.94849       -89.41506                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS       3238.543        3571.119  -42.57453   -33.34794
## 2     MA      10157.088       12403.788 -287.66556  -225.32383
## 3    SMA       5404.336        5736.847 -102.67036   -93.44378
## 
## Eigenvalues: 4831.897 0.4279791 
## 
## H statistic used for computing C.I. of MA: 2.312566e-07

Oceanic

## 
## Model II regression
## 
## Call: lmodel2(formula = DIC_umol_kg ~ BestSalinity, data =
## FLK.data_filtered[FLK.data_filtered$Zone == "Oceanic", ])
## 
## n = 188   r = 0.134705   r-square = 0.01814545 
## Parametric P-values:   2-tailed = 0.06531828    1-tailed = 0.03265914 
## Angle between the two OLS regression lines = 11.74937 degrees
## 
## Regression results
##   Method  Intercept      Slope Angle (degrees) P-perm (1-tailed)
## 1    OLS  1877.6544   4.716863        78.03022                NA
## 2     MA -7297.9453 259.739297        89.77941                NA
## 3    SMA   787.4959  35.016231        88.36418                NA
## 
## Confidence intervals
##   Method 2.5%-Intercept 97.5%-Intercept 2.5%-Slope 97.5%-Slope
## 1    OLS      1697.0471       2058.2617  -0.302165     9.73589
## 2     MA    147947.6176      -2480.2122 125.837421 -4055.08510
## 3    SMA       594.0374        955.2024  30.355074    40.39313
## 
## Eigenvalues: 437.9011 0.3506482 
## 
## H statistic used for computing C.I. of MA: 1.678203e-05

  1. Add TA and DIC endmembers (S=0) to data frame
# 4. Add endmember intercepts

  TA_SO<-subset(TA_coef, term=="(Intercept)")
  TA_SO<-as.data.frame(dplyr::select(TA_SO, c(Region, estimate)))
  names(TA_SO)[2] <- "TA_0"
  
  DIC_SO<-subset(DIC_coef, term=="(Intercept)")
  DIC_SO<-as.data.frame(dplyr::select(DIC_SO, c(Region, estimate)))
  names(DIC_SO)[2] <- "DIC_0"
    
  Intercepts<-join(TA_SO, DIC_SO, by="Region", type="full")
  FLK.data<-join(FLK.data, Intercepts, by="Region", type="left")
  1. Normalize with (1) Friss equation and (2) mean salinity
  # 5. endmember and salinity (mean) normalization
  FLK.data$nTA<-((
    (FLK.data$TA_umol_kg-FLK.data$TA_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$TA_0
  
  FLK.data$nDIC<-((
    (FLK.data$DIC_umol_kg-FLK.data$DIC_0)/
    FLK.data$BestSalinity)*MeanSalinity)+FLK.data$DIC_0
  
  # 2. TA and DIC 35 normalization
    FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*MeanSalinity
    # FLK.data$n35TA<-(FLK.data$TA_umol_kg/FLK.data$BestSalinity)*35
    # FLK.data$n35DIC<-(FLK.data$DIC_umol_kg/FLK.data$BestSalinity)*35
  
#write.csv(FLK.data, "FLK_results/FLK.data_filtered_normalized.csv", row.names = F)
  1. TA parameters to nTA (S=0)
kable(as.data.frame(TA_coef[,1:8], format = "markdown"), 
      caption = "Table 1: TA parameters for salinity normalization with endmember S=0",
      digits = 3)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 1: TA parameters for salinity normalization with endmember S=0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 2120.633 51.836 40.910 0 0.118 0.114
FL BestSalinity 7.235 1.440 5.023 0 0.118 0.114
#write.csv(TA_coef, "TA_coef.csv")
# Plot 
Normalization_plot<- ggplot(FLK.data) +
  theme_bw() +  
  theme(legend.position="bottom",
          plot.background=element_blank(),
          panel.grid.major.y = element_blank(),
          panel.grid.major.x = element_blank(),
          panel.grid.minor.x = element_blank(),
          panel.grid.minor.y = element_blank(),
          legend.box.background = element_rect(),
          legend.title = element_blank(),
          panel.background =element_rect(fill = NA, 
                                         color = "black"))+
         scale_x_continuous(limits = c(31.5, 39),
                     expand = c(0.05, 0.05),
                     breaks = seq(30, 40, 2),
                     name=expression(paste("Salinity")))
  1. DIC parameters to nDIC (S=0)
kable(as.data.frame(DIC_coef[,1:8], format = "markdown"), 
      caption = "Table 2: DIC parameters for salinity normalization with endmember S0",
      digits = 2) %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Table 2: DIC parameters for salinity normalization with endmember S0
Region term estimate std.error statistic p.value r.squared adj.r.squared
FL (Intercept) 1877.65 91.55 20.51 0.00 0.02 0.01
FL BestSalinity 4.72 2.54 1.85 0.07 0.02 0.01
#write.csv(DIC_coef, "DIC_coef.csv")

Figure Supp 1: Overview of linear regressions of total alkalinity (TA, µmol kg−1) and dissolved inorganic carbon (DIC, µmol kg−1) as a function of salinity + Friss normalized values.

  • Original data: Black line and circles
  • Friis normalization S0 end-member: purple line and pointing up triangles
  • Mean salinity normalization: purple line and pointing down triangles

TA vs Friss salinity normalized TA

Figure Supp X: Linear regressions of Friss normalized total alkalinity (nTA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Friss salinity normalized DIC

Figure Supp X: Linear regressions of Friss normalized Dissolved Inorganc Carbon (nDIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

TA vs Salinity normalized TA

Figure Supp X: Linear regressions of mean salinity normalized total alkalinity (n35TA, µmol kg−1) as a function of measured Total Alcalinity (TA, µmol kg−1)

DIC vs Salinity normalized DIC

Figure Supp X: Linear regressions of mean salinity normalized Dissolved Inorganc Carbon (n35DIC, µmol kg−1) as a function of measured Dissolved Inorganc Carbon (DIC, µmol kg−1)

Differences vs Salinity

Figure Supp X: Linear regressions of (A) TA-n35TA and (B) DIC-nDIC as a function of Salinity

4. Endmember comparissions

FLK.data_filtered<-FLK.data[FLK.data$Extreme=="Normal",]

4.1 TA and DIC relation

No_ocean.data<-FLK.data[FLK.data$Zone!="Oceanic",]

TA_DIC<- ggplot(No_ocean.data, aes (DIC_umol_kg, TA_umol_kg)) +

  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  scale_x_continuous(# limits = c(1600, 2600),
                     # expand = c(0, 0),
                     # breaks = seq(1500,2600,100),
                     expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  facet_grid(Sub_region~Zone)+ MyTheme+ 
  theme(legend.position = "bottom")+
  #Season_fill+ Season_colour+
  guides(fill=guide_legend(override.aes=list(shape=21)))
TA_DIC_Zone <- ddply (FLK.data[FLK.data$Extreme=="Normal", ], .(Zone),summarise,
                TAmean = mean (TA_umol_kg, na.rm = T), 
                DICmean = mean (DIC_umol_kg, na.rm = T),
                nTAmean = mean (n35TA, na.rm = T), 
                nDICmean = mean (n35DIC, na.rm = T),
                TAsd = sd (TA_umol_kg, na.rm = T), 
                DICsd = sd (DIC_umol_kg, na.rm = T),
                nTAsd = sd (n35TA, na.rm = T), 
                nDIsd = sd (n35DIC, na.rm = T))

TA_DIC_Ocean<-TA_DIC_Zone[TA_DIC_Zone$Zone=="Oceanic", ]

kable(as.data.frame(TA_DIC_Zone, format = "markdown"),
      caption = "Mean TA/DIC by zone") %>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
Mean TA/DIC by zone
Zone TAmean DICmean nTAmean nDICmean TAsd DICsd nTAsd nDIsd
Inshore 2342.749 2020.618 2338.706 2018.103 95.44205 110.31121 131.68054 146.51718
Mid channel 2365.490 2036.908 2363.258 2035.343 51.29212 59.06801 66.22381 77.00690
Offshore 2376.692 2047.068 2376.637 2046.982 20.01152 26.30078 39.47022 41.52785
Oceanic 2380.977 2047.365 2382.627 2048.922 12.51062 20.92593 38.18416 38.46281

Note: Use Model II Linear regressions!

“For Model II regressions, neither X nor Y is an INDEPENDENT variable but both are assumed to be DEPENDENT on some other parameter which is often unknown. Neither are”controlled”, both are measured, and both include some error. We do not seek an equation of how Y varies in response to a change in X, but rather we look for how they both co-vary in time or space in response to some other variable or process.”

Zone and region

# Individual LR for each Zone and Sub_region
    
TA_DIC_coef_zone_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_zone_noExtremes<-subset(TA_DIC_coef_zone_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_zone_noExtremes[,1:8], 
      format = "markdown"),
      caption = "TA vs DIC equations by zone and region without extreme events",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by zone and region without extreme events
Zone Sub_region term estimate std.error statistic p.value r.squared
Inshore BB DIC_umol_kg 0.64 0.04 15.06 0 0.74
Inshore UK DIC_umol_kg 0.57 0.03 18.59 0 0.78
Inshore MK DIC_umol_kg 0.79 0.04 22.52 0 0.81
Inshore LK DIC_umol_kg 0.85 0.04 22.46 0 0.80
Mid channel BB DIC_umol_kg 0.49 0.05 9.21 0 0.54
Mid channel UK DIC_umol_kg 0.32 0.06 5.51 0 0.31
Mid channel MK DIC_umol_kg 0.80 0.04 21.14 0 0.79
Mid channel LK DIC_umol_kg 0.80 0.04 21.50 0 0.79
Offshore BB DIC_umol_kg 0.50 0.07 7.22 0 0.40
Offshore UK DIC_umol_kg 0.44 0.05 8.79 0 0.42
Offshore MK DIC_umol_kg 0.70 0.04 17.75 0 0.72
Offshore LK DIC_umol_kg 0.50 0.04 12.24 0 0.49
#write.csv(TA_DIC_coef_zone_noExtremes, "FLK_results/Fig_2_TA_DIC_coef_slopes_Subregion.csv", row.names = FALSE)

# Annotations for plots
  coef_zone_noExtremes<-dplyr::select(TA_DIC_coef_zone_noExtremes, 
                               c("Zone", "Sub_region", "estimate", "r.squared"))
  coef_zone_noExtremes$estimate<-round(coef_zone_noExtremes$estimate, digits=2)
  coef_zone_noExtremes$r.squared<-round(coef_zone_noExtremes$r.squared, digits=2)

Type II Linear regression

TA_DIC_coef_zone_noExtII <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region) %>%
                    do({model = lmodel2(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
#TA_DIC_coef_zone_noExtII

TA_DIC_coef_zone_noExtII<-subset(TA_DIC_coef_zone_noExtII, term!="Intercept")
kable(as.data.frame(TA_DIC_coef_zone_noExtII[,1:9], 
      format = "markdown"),
      caption = "TA vs DIC equations without extreme events using type II lm",
      digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations without extreme events using type II lm
Zone Sub_region method term estimate conf.low conf.high p.value r.squared
Inshore BB MA Slope 0.71 0.62 0.81 0.74
Inshore BB OLS Slope 0.64 0.56 0.73 0.74
Inshore BB SMA Slope 0.75 0.67 0.84 0.74
Inshore UK MA Slope 0.61 0.54 0.67 0.78
Inshore UK OLS Slope 0.57 0.50 0.63 0.78
Inshore UK SMA Slope 0.64 0.58 0.70 0.78
Inshore MK MA Slope 0.86 0.79 0.94 0.81
Inshore MK OLS Slope 0.79 0.72 0.86 0.81
Inshore MK SMA Slope 0.88 0.81 0.95 0.81
Inshore LK MA Slope 0.95 0.87 1.03 0.80
Inshore LK OLS Slope 0.85 0.78 0.93 0.80
Inshore LK SMA Slope 0.95 0.88 1.03 0.80
Mid channel BB MA Slope 0.58 0.46 0.71 0.54
Mid channel BB OLS Slope 0.49 0.38 0.59 0.54
Mid channel BB SMA Slope 0.66 0.57 0.78 0.54
Mid channel UK MA Slope 0.40 0.26 0.55 0.31
Mid channel UK OLS Slope 0.32 0.20 0.43 0.31
Mid channel UK SMA Slope 0.57 0.47 0.70 0.31
Mid channel MK MA Slope 0.88 0.81 0.97 0.79
Mid channel MK OLS Slope 0.80 0.72 0.87 0.79
Mid channel MK SMA Slope 0.90 0.83 0.97 0.79
Mid channel LK MA Slope 0.89 0.81 0.97 0.79
Mid channel LK OLS Slope 0.80 0.72 0.87 0.79
Mid channel LK SMA Slope 0.90 0.83 0.97 0.79
Offshore BB MA Slope 0.69 0.51 0.90 0.40
Offshore BB OLS Slope 0.50 0.36 0.64 0.40
Offshore BB SMA Slope 0.79 0.66 0.94 0.40
Offshore UK MA Slope 0.56 0.44 0.69 0.42
Offshore UK OLS Slope 0.44 0.34 0.54 0.42
Offshore UK SMA Slope 0.68 0.58 0.78 0.42
Offshore MK MA Slope 0.79 0.71 0.88 0.72
Offshore MK OLS Slope 0.70 0.62 0.77 0.72
Offshore MK SMA Slope 0.82 0.75 0.90 0.72
Offshore LK MA Slope 0.63 0.53 0.73 0.49
Offshore LK OLS Slope 0.50 0.42 0.58 0.49
Offshore LK SMA Slope 0.72 0.64 0.80 0.49
# Annotations for plots
  TA_DIC_coef_zone_noExtII<-dplyr::select(TA_DIC_coef_zone_noExtII, 
                               c("Zone", "Sub_region","method", "estimate", "r.squared"))
  TA_DIC_coef_zone_noExtII$estimate<-round(TA_DIC_coef_zone_noExtII$estimate, digits=2)
  TA_DIC_coef_zone_noExtII$r.squared<-round(TA_DIC_coef_zone_noExtII$r.squared, digits=2)

4.2 By Precipitation - Removing Extreme events

TA_DIC_Extreme_pre<-TA_DIC + 
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Precipitation, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Precipitation), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+
  
  # geom_abline(slope = 0, intercept =TA_DIC_Ocean$TAmean, 
  #           linetype=2, colour="gray")+
  # geom_vline(xintercept = TA_DIC_Ocean$DICmean,
  #          linetype=2, colour="gray")+
  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_Extreme_pre

Zone, region and transect

TA_DIC_reef_pre<-TA_DIC_Extreme_pre + 
  facet_grid(Zone~Reference)
#TA_DIC_reef_pre
# Individual LR for each reef
TA_DIC_coef_Reef_noExtremes <- No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
            group_by(Zone, Sub_region, Reference, Precipitation) %>%
            do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
            data.frame(tidy(model), # get coefficient info
            glance(model))})        # get model info

TA_DIC_coef_Reef_noExtremes<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Reef_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by reef without extreme events per trsansec",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by reef without extreme events per trsansec
Zone Sub_region Reference Precipitation term estimate std.error statistic p.value r.squared adj.r.squared
Inshore BB BB_1 Dry DIC_umol_kg 0.55 0.06 8.67 0.00 0.79 0.78
Inshore BB BB_1 Wet DIC_umol_kg 0.72 0.06 11.10 0.00 0.87 0.86
Inshore BB BB_2 Dry DIC_umol_kg 0.52 0.07 7.40 0.00 0.75 0.74
Inshore BB BB_2 Wet DIC_umol_kg 0.47 0.12 4.00 0.00 0.50 0.47
Inshore UK UK_3 Dry DIC_umol_kg 0.56 0.03 17.91 0.00 0.90 0.90
Inshore UK UK_3 Wet DIC_umol_kg 0.47 0.09 5.16 0.00 0.50 0.48
Inshore UK UK_4 Dry DIC_umol_kg 0.53 0.05 10.75 0.00 0.88 0.87
Inshore UK UK_4 Wet DIC_umol_kg 0.32 0.15 2.20 0.04 0.23 0.18
Inshore MK MK_5 Dry DIC_umol_kg 0.55 0.07 8.14 0.00 0.79 0.77
Inshore MK MK_5 Wet DIC_umol_kg 0.66 0.09 6.99 0.00 0.73 0.72
Inshore MK MK_6 Dry DIC_umol_kg 0.70 0.09 7.50 0.00 0.77 0.75
Inshore MK MK_6 Wet DIC_umol_kg 0.79 0.11 7.11 0.00 0.73 0.71
Inshore MK MK_7 Dry DIC_umol_kg 0.66 0.08 8.47 0.00 0.82 0.81
Inshore MK MK_7 Wet DIC_umol_kg 0.87 0.13 6.93 0.00 0.72 0.70
Inshore LK LK_8 Dry DIC_umol_kg 0.77 0.10 8.04 0.00 0.77 0.76
Inshore LK LK_8 Wet DIC_umol_kg 0.83 0.09 8.77 0.00 0.81 0.80
Inshore LK LK_9 Dry DIC_umol_kg 0.66 0.09 7.26 0.00 0.75 0.73
Inshore LK LK_9 Wet DIC_umol_kg 0.75 0.14 5.35 0.00 0.61 0.59
Inshore LK LK_10 Dry DIC_umol_kg 0.83 0.14 5.90 0.00 0.62 0.61
Inshore LK LK_10 Wet DIC_umol_kg 0.71 0.12 5.84 0.00 0.64 0.62
Mid channel BB BB_1 Dry DIC_umol_kg 0.49 0.07 6.53 0.00 0.70 0.69
Mid channel BB BB_1 Wet DIC_umol_kg 0.56 0.12 4.76 0.00 0.57 0.55
Mid channel BB BB_2 Dry DIC_umol_kg 0.44 0.09 4.84 0.00 0.58 0.55
Mid channel BB BB_2 Wet DIC_umol_kg 0.26 0.13 1.96 0.07 0.20 0.15
Mid channel UK UK_3 Dry DIC_umol_kg 0.25 0.11 2.21 0.05 0.27 0.22
Mid channel UK UK_3 Wet DIC_umol_kg 0.03 0.13 0.22 0.83 0.00 -0.06
Mid channel UK UK_4 Dry DIC_umol_kg 0.44 0.10 4.54 0.00 0.56 0.54
Mid channel UK UK_4 Wet DIC_umol_kg 0.26 0.13 1.97 0.07 0.20 0.15
Mid channel MK MK_5 Dry DIC_umol_kg 0.41 0.10 4.11 0.00 0.47 0.44
Mid channel MK MK_5 Wet DIC_umol_kg 0.80 0.15 5.32 0.00 0.60 0.58
Mid channel MK MK_6 Dry DIC_umol_kg 0.58 0.09 6.14 0.00 0.68 0.66
Mid channel MK MK_6 Wet DIC_umol_kg 0.80 0.09 8.92 0.00 0.82 0.81
Mid channel MK MK_7 Dry DIC_umol_kg 0.58 0.09 6.74 0.00 0.73 0.71
Mid channel MK MK_7 Wet DIC_umol_kg 1.01 0.11 9.64 0.00 0.84 0.83
Mid channel LK LK_8 Dry DIC_umol_kg 0.55 0.15 3.57 0.00 0.39 0.36
Mid channel LK LK_8 Wet DIC_umol_kg 0.95 0.06 14.84 0.00 0.92 0.92
Mid channel LK LK_9 Dry DIC_umol_kg 0.65 0.10 6.36 0.00 0.68 0.66
Mid channel LK LK_9 Wet DIC_umol_kg 0.84 0.11 7.80 0.00 0.76 0.75
Mid channel LK LK_10 Dry DIC_umol_kg 0.41 0.16 2.52 0.02 0.23 0.20
Mid channel LK LK_10 Wet DIC_umol_kg 0.83 0.11 7.68 0.00 0.77 0.75
Offshore BB BB_1 Dry DIC_umol_kg 0.45 0.09 4.95 0.00 0.55 0.53
Offshore BB BB_1 Wet DIC_umol_kg 0.54 0.17 3.23 0.00 0.35 0.32
Offshore BB BB_2 Dry DIC_umol_kg 0.41 0.11 3.63 0.00 0.44 0.40
Offshore BB BB_2 Wet DIC_umol_kg 0.50 0.22 2.24 0.04 0.24 0.19
Offshore UK UK_3 Dry DIC_umol_kg 0.41 0.09 4.34 0.00 0.38 0.36
Offshore UK UK_3 Wet DIC_umol_kg 0.42 0.11 3.64 0.00 0.27 0.25
Offshore UK UK_4 Dry DIC_umol_kg 0.35 0.09 3.85 0.00 0.47 0.43
Offshore UK UK_4 Wet DIC_umol_kg 0.64 0.14 4.61 0.00 0.57 0.54
Offshore MK MK_5 Dry DIC_umol_kg 0.42 0.09 4.74 0.00 0.54 0.52
Offshore MK MK_5 Wet DIC_umol_kg 0.78 0.08 9.57 0.00 0.83 0.82
Offshore MK MK_6 Dry DIC_umol_kg 0.42 0.09 4.51 0.00 0.50 0.48
Offshore MK MK_6 Wet DIC_umol_kg 0.95 0.12 7.89 0.00 0.79 0.77
Offshore MK MK_7 Dry DIC_umol_kg 0.36 0.08 4.43 0.00 0.54 0.51
Offshore MK MK_7 Wet DIC_umol_kg 0.81 0.10 7.85 0.00 0.77 0.76
Offshore LK LK_8 Dry DIC_umol_kg 0.24 0.08 3.20 0.00 0.35 0.32
Offshore LK LK_8 Wet DIC_umol_kg 0.88 0.19 4.58 0.00 0.51 0.49
Offshore LK LK_9 Dry DIC_umol_kg 0.47 0.08 5.95 0.00 0.69 0.67
Offshore LK LK_9 Wet DIC_umol_kg 0.66 0.11 5.92 0.00 0.66 0.64
Offshore LK LK_10 Dry DIC_umol_kg 0.35 0.08 4.41 0.00 0.35 0.33
Offshore LK LK_10 Wet DIC_umol_kg 0.56 0.09 5.97 0.00 0.49 0.48
#write.csv (TA_DIC_coef_Reef_noExtremes, "FLK_results/Fig_2_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
TA_DIC_coef_Reef_noExtremes <- 
  No_ocean.data[No_ocean.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Transect, Precipitation) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_reef<-subset(TA_DIC_coef_Reef_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_reef, aes (x =Zone, y =estimate)) +
  MyTheme+
  scale_shape_manual(values=c(22, 23, 25))+
  geom_boxplot(aes(fill=(Precipitation)), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Precipitation)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  theme(axis.text.x = element_text(angle = 0, vjust = 0.1),
        legend.position = "bottom")+
  #guides(fill=FALSE)+
  facet_grid(Sub_region~Region)
  # Season_fill+ Season_colour+
  # theme(legend.title = element_blank())
#Slope_plot

Figure S9: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

4.3 By Season - Removing Extreme events

TA_DIC_season<-TA_DIC + 
  Season_colour+ Season_fill+
  geom_abline(intercept = -1700, slope=2, color="grey")+
  geom_hline (yintercept = TA_DIC_Ocean$TAmean, color="grey")+
  scale_shape_manual(values=c(24, 25, 21))+
  geom_point(data=No_ocean.data, aes (DIC_umol_kg, TA_umol_kg,
                                 fill=Season, shape=Extreme),
                            alpha=0.5, size=1)+
  geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg), 
              method = "lm", colour="black", se=F)+
  
   geom_smooth(data=No_ocean.data[No_ocean.data$Extreme=="Normal", ], 
              aes(DIC_umol_kg, TA_umol_kg, colour=Season), 
              method = "lm", se=F, size=0.5)+
  
  geom_text(data = coef_zone_noExtremes, 
            aes(x = TA_DIC_Ocean$DICmean, y = 2070,
                label = paste("Slo =", estimate,  
                              " r.sq=", r.squared)),
            size=2.5)+

  geom_point(aes(x=TA_DIC_Ocean$DICmean, y=TA_DIC_Ocean$TAmean),
             size=3, alpha=1, shape=21, fill="black")
#TA_DIC_season
# Individual LR for each reef
TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Sub_region, Season) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info

TA_DIC_coef_Season_noExtremes<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")
kable(as.data.frame(TA_DIC_coef_Season_noExtremes[,1:11],
                      format = "markdown"),
        caption = "TA vs DIC equations by season without extreme events",
        digits = 2)%>% 
kable_styling(bootstrap_options = c("striped", "condensed", full_width = F), font_size = 11)
TA vs DIC equations by season without extreme events
Zone Sub_region Season term estimate std.error statistic p.value r.squared adj.r.squared sigma
Inshore BB Winter DIC_umol_kg 0.67 0.10 6.59 0.00 0.74 0.73 23.70
Inshore BB Spring DIC_umol_kg 0.86 0.11 7.52 0.00 0.75 0.74 36.03
Inshore BB Summer DIC_umol_kg 0.53 0.11 4.95 0.00 0.58 0.55 33.48
Inshore BB Fall DIC_umol_kg 0.78 0.09 8.29 0.00 0.77 0.75 23.40
Inshore UK Winter DIC_umol_kg 0.71 0.05 13.83 0.00 0.91 0.90 21.12
Inshore UK Spring DIC_umol_kg 0.58 0.06 8.96 0.00 0.76 0.75 22.93
Inshore UK Summer DIC_umol_kg 0.57 0.19 2.98 0.01 0.27 0.24 42.13
Inshore UK Fall DIC_umol_kg 0.71 0.06 11.46 0.00 0.84 0.83 26.86
Inshore MK Winter DIC_umol_kg 0.84 0.08 10.16 0.00 0.84 0.83 34.06
Inshore MK Spring DIC_umol_kg 0.84 0.10 8.32 0.00 0.68 0.67 41.83
Inshore MK Summer DIC_umol_kg 0.95 0.07 13.67 0.00 0.87 0.87 37.15
Inshore MK Fall DIC_umol_kg 0.79 0.07 10.76 0.00 0.79 0.78 28.77
Inshore LK Winter DIC_umol_kg 0.64 0.12 5.22 0.00 0.51 0.49 44.09
Inshore LK Spring DIC_umol_kg 0.87 0.08 10.52 0.00 0.77 0.76 35.49
Inshore LK Summer DIC_umol_kg 0.97 0.08 12.26 0.00 0.86 0.86 36.38
Inshore LK Fall DIC_umol_kg 1.04 0.06 17.57 0.00 0.90 0.90 26.09
Mid channel BB Winter DIC_umol_kg 0.80 0.12 6.54 0.00 0.75 0.74 9.85
Mid channel BB Spring DIC_umol_kg 0.64 0.08 7.88 0.00 0.80 0.78 11.95
Mid channel BB Summer DIC_umol_kg 0.39 0.14 2.82 0.01 0.31 0.27 19.66
Mid channel BB Fall DIC_umol_kg 0.48 0.09 5.22 0.00 0.59 0.57 11.79
Mid channel UK Winter DIC_umol_kg 0.66 0.09 7.62 0.00 0.82 0.80 13.29
Mid channel UK Spring DIC_umol_kg 0.01 0.13 0.04 0.97 0.00 -0.07 13.59
Mid channel UK Summer DIC_umol_kg 0.26 0.12 2.11 0.05 0.22 0.17 20.02
Mid channel UK Fall DIC_umol_kg 0.43 0.11 4.02 0.00 0.49 0.46 14.77
Mid channel MK Winter DIC_umol_kg 0.72 0.07 10.08 0.00 0.82 0.81 21.50
Mid channel MK Spring DIC_umol_kg 0.97 0.08 11.47 0.00 0.81 0.80 29.81
Mid channel MK Summer DIC_umol_kg 1.02 0.08 12.57 0.00 0.85 0.84 24.56
Mid channel MK Fall DIC_umol_kg 0.57 0.06 8.91 0.00 0.72 0.71 16.21
Mid channel LK Winter DIC_umol_kg 0.73 0.14 5.10 0.00 0.48 0.46 35.75
Mid channel LK Spring DIC_umol_kg 0.74 0.08 9.40 0.00 0.73 0.73 27.01
Mid channel LK Summer DIC_umol_kg 0.92 0.05 18.78 0.00 0.93 0.93 17.99
Mid channel LK Fall DIC_umol_kg 0.62 0.13 4.84 0.00 0.41 0.39 19.83
Offshore BB Winter DIC_umol_kg 0.74 0.12 5.98 0.00 0.70 0.68 8.49
Offshore BB Spring DIC_umol_kg 0.48 0.13 3.63 0.00 0.41 0.38 8.38
Offshore BB Summer DIC_umol_kg 0.59 0.21 2.84 0.01 0.31 0.27 20.07
Offshore BB Fall DIC_umol_kg 0.34 0.07 4.65 0.00 0.52 0.50 8.52
Offshore UK Winter DIC_umol_kg 0.63 0.08 8.01 0.00 0.75 0.74 6.58
Offshore UK Spring DIC_umol_kg 0.48 0.17 2.86 0.01 0.25 0.22 10.70
Offshore UK Summer DIC_umol_kg 0.48 0.11 4.52 0.00 0.44 0.42 14.09
Offshore UK Fall DIC_umol_kg 0.29 0.08 3.42 0.00 0.30 0.28 11.49
Offshore MK Winter DIC_umol_kg 0.62 0.09 6.95 0.00 0.68 0.66 8.56
Offshore MK Spring DIC_umol_kg 0.89 0.07 12.65 0.00 0.84 0.83 13.80
Offshore MK Summer DIC_umol_kg 0.75 0.08 9.42 0.00 0.76 0.75 16.30
Offshore MK Fall DIC_umol_kg 0.34 0.06 5.43 0.00 0.48 0.46 9.89
Offshore LK Winter DIC_umol_kg 0.48 0.09 5.28 0.00 0.47 0.45 10.09
Offshore LK Spring DIC_umol_kg 0.61 0.08 7.90 0.00 0.61 0.60 11.79
Offshore LK Summer DIC_umol_kg 0.60 0.11 5.36 0.00 0.45 0.43 17.60
Offshore LK Fall DIC_umol_kg 0.24 0.05 4.84 0.00 0.35 0.34 7.77
Oceanic UK Winter DIC_umol_kg 0.74 0.10 7.49 0.00 0.90 0.89 4.81
Oceanic UK Spring DIC_umol_kg 0.17 0.21 0.82 0.44 0.09 -0.04 5.84
Oceanic UK Summer DIC_umol_kg 0.39 0.26 1.51 0.18 0.28 0.15 18.65
Oceanic UK Fall DIC_umol_kg 0.24 0.14 1.76 0.12 0.31 0.21 10.38
Oceanic MK Winter DIC_umol_kg 0.58 0.07 8.35 0.00 0.83 0.82 5.13
Oceanic MK Spring DIC_umol_kg 0.45 0.12 3.77 0.00 0.47 0.44 8.16
Oceanic MK Summer DIC_umol_kg 0.45 0.12 3.91 0.00 0.46 0.43 12.37
Oceanic MK Fall DIC_umol_kg 0.30 0.09 3.12 0.01 0.34 0.30 9.95
Oceanic LK Winter DIC_umol_kg 0.45 0.15 3.02 0.01 0.35 0.31 11.24
Oceanic LK Spring DIC_umol_kg 0.51 0.11 4.73 0.00 0.53 0.50 8.38
Oceanic LK Summer DIC_umol_kg 0.43 0.09 4.62 0.00 0.59 0.56 9.31
Oceanic LK Fall DIC_umol_kg 0.24 0.07 3.54 0.00 0.40 0.37 6.98
#write.csv (TA_DIC_coef_Season_noExtremes, "FLK_results/Fig_5_TA_DIC_slopes_Reefs.csv", row.names = FALSE)
  
  
  TA_DIC_coef_Season_noExtremes <- FLK.data[FLK.data$Extreme=="Normal", ] %>% 
                    group_by(Zone, Region, Sub_region, Season, Transect) %>%
                    do({model = lm(TA_umol_kg~DIC_umol_kg, data=.)  
                    # create model
                    data.frame(tidy(model), # get coefficient info
                    glance(model))})        # get model info
Slopes_season<-subset(TA_DIC_coef_Season_noExtremes, term!="(Intercept)")

Slope_plot<-ggplot(data=Slopes_season, aes (x =Zone, y =estimate)) +
  MyTheme+
  Zone_shapes4+
  geom_boxplot(aes(fill=Season), alpha=0.5,
               position=position_dodge(width=0.3))+
  geom_point(aes(fill = factor(Season)), 
              position=position_dodge(width=0.3),
             shape = 21, size=0.5)+
  scale_y_continuous(#limits = c(1700,2900),
                     #expand = c(0, 0),
                     #breaks = seq(1800, 2800, 100),
                     expression(paste("TA vs DIC slope")))+
  facet_grid(Sub_region~Region)+
  Season_fill+
  Season_colour+
  guides(fill=FALSE)+
  theme(axis.text.x = element_text(angle = 90, vjust = 0.1),
        legend.position = "bottom")
#Slope_plot

Figure 6: TA (µmol kg−1) vs DIC (µmol kg−1) slopes per season and reef

5 Seasonal plots

Data for endmember comparisons

# Reef
  WS.reef<-subset(FLK.data, FLK.data$Zone!="Oceanic")
  WS.reef$Date<-as.Date(WS.reef$Date, "%Y-%m-%d")
  
# Open
  WS.open<-subset(FLK.data_filtered,
                  FLK.data_filtered$Zone=="Oceanic")
  WS.open$Date<-as.Date(WS.open$Date, "%Y-%m-%d")
  #summary(WS.open)
# Mean ocean values by month - year 
  mean_Open_MY<- ddply (WS.open, .(MY, Month),
                            summarise,
                  OTem_my = mean (Temperature_C, na.rm = T),  
                  OSal_my = mean (BestSalinity, na.rm = T), 
                  
                  OTA_my = mean (TA_umol_kg, na.rm = T),
                  OnTA_my = mean (n35TA, na.rm = T),
                  
                  ODIC_my = mean (DIC_umol_kg, na.rm = T),
                  OnDIC_my = mean (n35DIC, na.rm = T),
                  
                  OpCO2_O = mean (pCO2_uatm , na.rm = T),
                  OpH_O = mean (pH_calculated, na.rm = T),
                  OAra_O = mean (Aragonite_Sat_W , na.rm = T)
                  )

# Mean ocean values by month
  mean_OpM <- mean_Open_MY %>%
              group_by(Month) %>%
              summarise(
                  OTem_m = mean (OTem_my, na.rm = T), 
                  OSal_m = mean (OSal_my, na.rm = T), 
                  
                  OTA_m = mean (OTA_my, na.rm = T),
                  OnTA_m = mean (OnTA_my, na.rm = T),
                  
                  OnDIC_m = mean (OnDIC_my, na.rm = T),
                  ODIC_m = mean (ODIC_my, na.rm = T),
                  
                  OpCO2_m = mean (OpCO2_O , na.rm = T),
                  OpH_m = mean (OpH_O, na.rm = T),
                  OAra_m = mean (OAra_O, na.rm = T),
                  n = n()
                  )
   #mean_OpM
  
 # Mean ocean values by year    
  mean_Op<- mean_OpM %>%
            summarise(
                  OTem = mean (OTem_m, na.rm = T), 
                  OSal  = mean (OSal_m, na.rm = T), 
                  
                  OTA = mean (OTA_m, na.rm = T),
                  OnTA = mean (OnTA_m, na.rm = T),
                  
                  OnDIC = mean (OnDIC_m, na.rm = T),
                  ODIC = mean (ODIC_m, na.rm = T),
                  
                  OpCO2 = mean (OpCO2_m, na.rm = T),
                  OpH = mean (OpH_m, na.rm = T),
                  OAra = mean (OAra_m, na.rm = T),
                  n = n()
                  )

5.1 Month raw values

- Months stats

Month_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region),
                            summarise,
                       
                  Tem_mean = mean (Temperature_C, na.rm = T),
                  Tem_sd = sd (Temperature_C, na.rm = T),
                  #Tem_se = std.error (Temperature_C, na.rm = T),
                  
                  Sal_mean = mean (BestSalinity, na.rm = T),
                  Sal_sd = sd (BestSalinity, na.rm = T),
                  #Sal_se = std.error (BestSalinity, na.rm = T),
                       
                  TA_mean = mean (TA_umol_kg, na.rm = T),
                  TA_sd = sd (TA_umol_kg, na.rm = T),
                  #TA_se = std.error (TA_umol_kg, na.rm = T),
                  
                  nTA_mean = mean (n35TA, na.rm = T),
                  nTA_sd = sd (n35TA, na.rm = T),
                  
                  DIC_mean = mean (DIC_umol_kg, na.rm = T),
                  DIC_sd = sd (DIC_umol_kg, na.rm = T),
                  #DIC_se = std.error (DIC_umol_kg, na.rm = T),
                  
                  nDIC_mean = mean (n35DIC, na.rm = T),
                  nDIC_sd = sd (n35DIC, na.rm = T),
                  
                  pCO2_mean = mean (pCO2_uatm , na.rm = T),
                  pCO2_sd = sd (pCO2_uatm , na.rm = T),
                  #pCO2_se = std.error (pCO2_uatm, na.rm = T),
                  
                  pH_mean = mean (pH_calculated, na.rm = T),
                  pH_sd = sd (pH_calculated, na.rm = T),
                  #pH_se = std.error (pH_calculated, na.rm = T),
                  
                  Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
                  Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
                  #Ara_se = std.error (Aragonite_Sat_W, na.rm = T),
                  n = n())

Month_Stats_2d<-Month_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
Month_Stats_2d
#write.csv(Month_Stats, "FLK_results/Table_S7_Month_Stats.csv", row.names = F)

Temp

Month_Temp<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Temperature_C, na.rm = T),
                  sd = sd (Temperature_C, na.rm = T))

Month_Temp<-Month_Temp %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Temp$Region<-NULL

Month_Temp<-reshape(Month_Temp, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Sal

Month_Sal<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (BestSalinity, na.rm = T),
                  sd = sd (BestSalinity, na.rm = T))

Month_Sal<-Month_Sal %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Sal$Region<-NULL

Month_Sal<-reshape(Month_Sal, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

TA

Month_TA<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (TA_umol_kg, na.rm = T),
                  sd = sd (TA_umol_kg, na.rm = T))

Month_TA<-Month_TA %>% 
 mutate_if(is.numeric, round, digits=2)
Month_TA$Region<-NULL

Month_TA<-reshape(Month_TA, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

DIC

Month_DIC<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (DIC_umol_kg, na.rm = T),
                  sd = sd (DIC_umol_kg, na.rm = T))

Month_DIC<-Month_DIC %>% 
 mutate_if(is.numeric, round, digits=2)
Month_DIC$Region<-NULL

Month_DIC<-reshape(Month_DIC, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pCO2

Month_pCO2<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pCO2_uatm , na.rm = T),
                  sd = sd (pCO2_uatm , na.rm = T))

Month_pCO2<-Month_pCO2 %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pCO2$Region<-NULL

Month_pCO2<-reshape(Month_pCO2, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

pH

Month_pH<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (pH_calculated, na.rm = T),
                  sd = sd (pH_calculated, na.rm = T))

Month_pH<-Month_pH %>% 
 mutate_if(is.numeric, round, digits=2)
Month_pH$Region<-NULL

Month_pH<-reshape(Month_pH, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

Arag

Month_Ara<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season, Month2, Region), summarise,
                     
                  mean = mean (Aragonite_Sat_W , na.rm = T),
                  sd = sd (Aragonite_Sat_W , na.rm = T))

Month_Ara<-Month_Ara %>% 
 mutate_if(is.numeric, round, digits=2)
Month_Ara$Region<-NULL

Month_Ara<-reshape(Month_Ara, idvar = c("Sub_region", 
                                          "Season", "Month2"),
                    timevar = "Zone", direction = "wide")

all

Month_Stats3<-rbind(Month_Temp, Month_Sal, Month_TA, Month_DIC, 
      Month_pCO2, Month_pH, Month_Ara)

#write.csv(Month_Stats3, "FLK_results/Table_S7_Month_Stats_wide.csv", row.names = F)

Seasonal range

Seasonal_range<-ddply (Month_Stats, .(Zone, Sub_region),
                            summarise,
                  Tem_meany = mean (Tem_mean, na.rm = T),
                  Tem_sdy = sd (Tem_mean, na.rm = T),
                  Tem_max = max (Tem_mean, na.rm = T),
                  Tem_min = min (Tem_mean, na.rm = T),
                  Tem_diff = (max (Tem_mean, na.rm = T) - min (Tem_mean, na.rm = T)),
                  
                 Sal_meany = mean (Sal_mean, na.rm = T),
                 Sal_sdy = sd (Sal_mean, na.rm = T),
                 Sal_max = max (Sal_mean, na.rm = T),
                  Sal_min = min (Sal_mean, na.rm = T),
                  Sal_diff = (max (Sal_mean, na.rm = T) - min (Sal_mean, na.rm = T)),
                  
                 TA_meany = mean (TA_mean, na.rm = T),
                 TA_sdy = sd (TA_mean, na.rm = T), 
                 TA_max = max (TA_mean, na.rm = T),
                  TA_min = min (TA_mean, na.rm = T),
                  TA_diff = (max (TA_mean, na.rm = T) - min (TA_mean, na.rm = T)),
                  
                 DIC_meany = mean (DIC_mean, na.rm = T),
                  DIC_sdy = sd (DIC_mean, na.rm = T), 
                 DIC_max = max (DIC_mean, na.rm = T),
                  DIC_min = min (DIC_mean, na.rm = T),
                  DIC_diff = (max (DIC_mean, na.rm = T) - min (DIC_mean, na.rm = T)),
                  
                 pCO2_meany = mean (pCO2_mean, na.rm = T),
                 pCO2_sdy = sd (pCO2_mean, na.rm = T), 
                  pCO2_max = max (pCO2_mean, na.rm = T),
                  pCO2_min = min (pCO2_mean, na.rm = T),
                  pCO2_dif = (max (pCO2_mean, na.rm = T) - min (pCO2_mean, na.rm = T)),
                  
                 pH_meany = mean (pH_mean, na.rm = T),
                  pH_sdy = sd (pH_mean, na.rm = T), 
                 pH_max = max (pH_mean, na.rm = T),
                  pH_min = min (pH_mean, na.rm = T),
                  pH_diff = (max (pH_mean, na.rm = T) - min (pH_mean, na.rm = T)),
                  
                 Arg_meany = mean (Ara_mean, na.rm = T),
                 Arg_sdy = sd (Ara_mean, na.rm = T),  
                 Ara_max = max (Ara_mean, na.rm = T),
                  Ara_min = min (Ara_mean, na.rm = T),
                  Ara_diff = (max (Ara_mean, na.rm = T) - min (Ara_mean, na.rm = T)),
                  
                  
                  nTA_max = max (nTA_mean, na.rm = T),
                  nTA_min = min (nTA_mean, na.rm = T),
                  nTA_diff = (max (nTA_mean, na.rm = T) - min (nTA_mean, na.rm = T)),
                  
                  nDIC_max = max (nDIC_mean, na.rm = T),
                  nDIC_min = min (nDIC_mean, na.rm = T),
                  nDIC_diff = (max (nDIC_mean, na.rm = T) - min (nDIC_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range<-Seasonal_range %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_range
#Seasonal_range$pH_max_diff<-Seasonal_range$pH_max-mean()

#write.csv(Seasonal_range, "FLK_results/Table_S8_Month_mean_range.csv", row.names = F)

- Month Plots

Month_ploth<- ggplot(FLK.data) +
        MyTheme +  
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank() )

Year_ploth<- ggplot(Month_Stats) +
        MyTheme +  
        theme(axis.title.x = element_blank(), axis.text.x=element_text(angle = 10, vjust = 0.5))+
        Season_fill+
        Season_colour+
        facet_grid(Sub_region~Region)
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        #theme(axis.title.x = element_blank() )

Month_Season_plotTA_DIC<- ggplot(FLK.data_filtered[
          FLK.data_filtered$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(#strip.text = element_blank(),
              legend.position = "none",
              axis.title.x = element_blank()
              )

Month_Season_plot<- ggplot(FLK.data_filtered) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        #Region_fill+
        #Region_colour+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                   expand = c(0.05, 0.05),
                   breaks = seq(1, 12, 1),
                   name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank())#,
        #       legend.position = "none")

Year_plot_2<- ggplot(Month_Stats)+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        facet_grid(~Zone)+
        Zone_shapes4+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        #Season_fill+
        #Season_colour+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "bottom"
              )

Year_plot_3<- ggplot(Month_Stats, aes(fill=Sub_region, shape=Zone))+
#[Month_Stats$Zone!="Oceanic",]) +
        MyTheme +  
        Zone_shapes4+
        facet_grid(~Region)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(#axis.title.x = element_blank()#,
              #axis.text.y=element_blank(),
              legend.position = "right",
              axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 20, vjust = 0.5)
              )

Temperature

Figure Supp 2: Temperature variation by the region and shelf position by (A) month of the year and (B) season.

Temp_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OTem, color="grey")+
    scale_y_continuous(#limits = c(15,40),
                       name=(expression("Temperature"~(degree*C))),
                       breaks = seq(16, 40, 2),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                span=0.6, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=Temperature_C, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Temperature_C, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Temp_exp

Salinity

Figure Supp 3: Salinity variation by the region and shelf position by (A) month of the year and (B) season.

Sal_exp<- Month_Season_plot+
  geom_abline(slope = 0, intercept = mean_Op$OSal, color="grey")+
   scale_y_continuous(#limits = c(15,40),
                       name=(expression("Salinity")),
                       breaks = seq(15, 40, 1),  
                       expand = c(0.05, 0.05)) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=BestSalinity, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=BestSalinity, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#Sal_exp

TA

Figure Supp XX: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3A

TA_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2100,2500),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                span=0.8, alpha=0.2, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=TA_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=TA_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))
    
#


TA_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.05, 0.05),
                     breaks = seq(2200, 2500, 50),
                    name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   stat_summary(aes (x=Sub_region, y=TA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2)+
   stat_summary(aes (x=Sub_region, y=TA_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#TA_Y2

TA_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OTA, color="grey")+
   scale_y_continuous(limits = c(2130,2510),
                     expand = c(0.05, 0.05),
                     breaks = seq(2100, 2500, 100),
                     name=expression(paste("TA (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=TA_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = TA_min, 
   #                  xend = Zone, yend = TA_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=TA_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
   stat_summary(aes (x=Zone, y=TA_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#TA_Y3

Figure 3A: Total Alkalinity (TA) variation by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

nTA

DIC

Figure Supp XX: Disolved Inorganic Carbon (DIC) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3B

DIC_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1780,2270),
                     expand = c(0.05, 0.05),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    geom_smooth(aes (x=as.numeric(Month2),
                    y=DIC_umol_kg, colour=Sub_region),
                    span=0.8, alpha=0.2, se=F)+
   
    stat_summary(aes (x=as.numeric(Month2),
                      y=DIC_umol_kg, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width=0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=DIC_umol_kg, fill=Sub_region, shape=Zone),
                size=1,
                fun = "mean", geom = "point",
                position=position_dodge(width=0.3))
#DIC_exp

DIC_Y2<- Year_plot_2+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
    
   stat_summary(aes (x=Sub_region, y=DIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
   stat_summary(aes (x=Sub_region, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point",
                size=2)
#DIC_Y2

DIC_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$ODIC, color="grey")+
   scale_y_continuous(limits = c(1820,2230),
                     expand = c(0.00, 0.00),
                     breaks = seq(1800, 2800, 100),
                     name=expression(paste("DIC (", mu, "mol ", kg^-1, ")")))+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=DIC_min,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
  # geom_segment(data=Seasonal_range, 
  #               aes(   x = Zone, y = DIC_min, 
  #                   xend = Zone, yend = DIC_max,
  #                   colour=Sub_region),
  #               #position = position_dodge(width = 0.6), 
  #               alpha=0.3)+
   stat_summary(aes (x=Zone, y=DIC_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=DIC_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#DIC_Y3

Figure 3B: Dissolved Inorganic Carbon (DIC) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values

nDIC

pCO2

Figure Supp 6: pCO2 variation by the region and shelf position by (A) month of the year and (B) season.

pCO2_exp<- Month_Season_plot+
   geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
     scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], " (", mu, " atm)")),
                       breaks = seq(200, 600, 100),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=pCO2_uatm, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pCO2_uatm, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pCO2_exp

pCO2_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpCO2, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       name=expression(paste(pCO[2], 
                                             " (", mu, " atm)")),
                       breaks = seq(200, 600, 50),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pCO2_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
  stat_summary(aes (x=Sub_region, y=pCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pCO2_Y2

pH

Figure Supp 7: pH variation by the region and shelf position by (A) month of the year and (B) season.

pH_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(7.88,8.25),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        ) +
    
    geom_smooth(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                span=0.8, se=F)+
    
    stat_summary(aes (x=as.numeric(Month2),
                      y=pH_calculated, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
     stat_summary(aes (x=as.numeric(Month2), 
                      y=pH_calculated, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pH_exp

pH_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (pH[calculated])),
                       breaks = seq(0, 9, 0.05),
                       expand = c(0.05, 0.05)
                        ) +
    
   stat_summary(aes (x=Sub_region, y=pH_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)+
    stat_summary(aes (x=Sub_region, y=pH_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)
#pH_Y2

pH_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OpH, color="grey")+
   scale_y_continuous(limits = c(7.87,8.22),
                       name=(expression (pH)),
                       breaks = seq(0, 9, 0.1),
                       expand = c(0.02, 0)
                        )+
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=pH_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = pH_min, 
   #                  xend = Zone, yend = pH_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=pH_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=pH_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#pH_Y3

Figure 3C

Omega

Figure Supp 8: Omega variation by the region and shelf position by (A) month of the year and (B) season.

Figure 3D

Omega_exp<- Month_Season_plot+
    geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
    scale_y_continuous(#limits = c(1,5.5),
                       name=(expression("\n" ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                span=0.8, alpha=0.2, se=F
                #method = lm, formula = y ~ splines::bs(x, 3),
                )+
      stat_summary(aes (x=as.numeric(Month2),
                      y=Aragonite_Sat_W, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.3))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=Aragonite_Sat_W, fill=Sub_region, shape=Zone),
                size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.3))

#Omega_exp

Om_Y2<- Year_plot_2+
  geom_abline(slope = 0, intercept = mean_Op$OAra, color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
    
  stat_summary(aes (x=Sub_region, y=Ara_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar",  width = 0.2)+
  stat_summary(aes (x=Sub_region, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=2)
#Om_Y2

Om_Y3<- Year_plot_3+
   geom_abline(slope = 0, intercept = mean_Op$OAra , color="grey")+
  scale_y_continuous(#limits = c(1,5.5),
                       # name=(expression (
                       #   "Aragonite saturation state "(~Omega[Ar]))),
                      name=(expression (
                      ~Omega[Ar])),
                       breaks = seq(1, 5, 0.5),
                       expand = c(0.1, 0.1)
                        ) +
  
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_max,
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1, 
              position = position_dodge(width = 0.6))+
   geom_point(data=Seasonal_range, aes (x=Zone, y=Ara_min, 
                   shape=Zone, colour=Sub_region),
              alpha=0.8, size=1,
              position = position_dodge(width = 0.6))+
   # geom_segment(data=Seasonal_range, 
   #              aes(   x = Zone, y = Ara_min, 
   #                  xend = Zone, yend = Ara_max,
   #                  colour=Sub_region),
   #              #position = position_dodge(width = 0.6), 
   #              alpha=0.3)+
   stat_summary(aes (x=Zone, y=Ara_mean, colour=Sub_region),
               fun.data = "mean_sdl", fun.args = list(mult = 1),
                geom = "errorbar",  width = 0.2,
                position = position_dodge(width = 0.6))+
  stat_summary(aes (x=Zone, y=Ara_mean, fill=Sub_region, shape=Zone),
                fun = "mean", 
                geom = "point", size=2,
                position = position_dodge(width = 0.6))
#Om_Y3

Figure 3C: Aragonite saturation state (omega) by the region and shelf position. Left: monthly mean values, Right: Yearly mean values + SD, maximum monthly mean and minimum monthly mean.

Fig.3: Seasonal monthly plot

No summary

with summary

Fig.3: Seasonal monthly plot supplemental

Figure 3: Monthly seasonal patterns in (A) Total Alkalinity (TA), (B) Dissolved Inorganic Carbon (DIC), and (C) aragonite saturation state (Ωar) in the Florida Reef Tract. The colors represent the biogeographical regions and the vertical panels separate the locations by shelf zone. The points show the (monthly mean values ± 95 CI) and the lines the smoothed curves for the data (method = ‘loess’ and formula ‘y ~ x’, span=0.8). Gray horizontal lines in each panel demarcate the mean values of the parameters in the oceanic samples.

5.2 Season raw values

- Season stats (all data)

  • do not use for further calculations since some months have more data than
  • can be used to compare the aggregated meas ussing MM
Seasonal_Stats<- ddply (FLK.data_filtered, .(Zone, Sub_region, Season),
             summarise,

      Tem_mean = mean (Temperature_C, na.rm = T),
      Tem_sd = sd (Temperature_C, na.rm = T),
    
      Sal_mean = mean (BestSalinity, na.rm = T),
      Sal_sd = sd (BestSalinity, na.rm = T),
    
      TA_mean = mean (TA_umol_kg, na.rm = T),
      TA_sd = sd (TA_umol_kg, na.rm = T),
    
      nTA_mean = mean (n35TA, na.rm = T),
      nTA_sd = sd (n35TA, na.rm = T),
    
      nDIC_mean = mean (n35DIC, na.rm = T),
      nDIC_sd = sd (n35DIC, na.rm = T),
    
      DIC_mean = mean (DIC_umol_kg, na.rm = T),
      DIC_sd = sd (DIC_umol_kg, na.rm = T),
    
      pCO2_mean = mean (pCO2_uatm , na.rm = T),
      pCO2_sd = sd (pCO2_uatm , na.rm = T),
    
      pH_mean = mean (pH_calculated, na.rm = T),
      pH_sd = sd (pH_calculated, na.rm = T),
    
      Ara_mean = mean (Aragonite_Sat_W , na.rm = T),
      Ara_sd = sd (Aragonite_Sat_W , na.rm = T),
       n())

Seasonal_Stats<-Seasonal_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats

- Season stats (monthly mean)

Seasonal_Stats2<- ddply (Month_Stats, .(Zone, Sub_region, Season),
                         summarise,

                  Tem_M = mean (Tem_mean, na.rm = T),
                  #Tem_sd = sd (Tem_mean, na.rm = T),
                  Tem_se = std.error (Tem_mean, na.rm = T),

                  Sal_M = mean (Sal_mean, na.rm = T),
                  #Sal_sd = sd (Sal_mean, na.rm = T),
                  Sal_se = std.error (Sal_mean, na.rm = T),

                  TA_M = mean (TA_mean, na.rm = T),
                  #TA_sd = sd (TA_mean, na.rm = T),
                  TA_se = std.error (TA_mean, na.rm = T),
                  
                  DIC_M = mean (DIC_mean, na.rm = T),
                  #DIC_sd = sd (DIC_mean, na.rm = T),
                  DIC_se = std.error (DIC_mean, na.rm = T),
                  
                  #nTA_M = mean (nTA_mean, na.rm = T),
                  #nTA_sd = sd (nTA_mean, na.rm = T),
                  
                  #nDIC_M = mean (nDIC_mean, na.rm = T),
                  #nDIC_sd = sd (nDIC_mean, na.rm = T),

                  pCO2_M = mean (pCO2_mean , na.rm = T),
                  #pCO2_sd = sd (pCO2_mean , na.rm = T),
                  pCO2_se = std.error (pCO2_mean , na.rm = T),

                  pH_M = mean (pH_mean, na.rm = T),
                  #pH_sd = sd (pH_mean, na.rm = T),
                  pH_se = std.error (pH_mean, na.rm = T),

                  Ara_M = mean (Ara_mean , na.rm = T),
                  #Ara_sd = sd (Ara_mean , na.rm = T),
                  Ara_se = std.error (Ara_mean , na.rm = T),
                  n())

Seasonal_Stats2<-Seasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=2)
Seasonal_Stats2
# write.csv(Seasonal_Stats2, "FLK_results/Table_S_Season_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Yearly stats (monthly mean)

Yearly_Stats<- ddply (Month_Stats, .(Zone, Sub_region),
                         summarise,

                  Tem_Y = mean (Tem_mean, na.rm = T),
                  Tem_sd = sd (Tem_mean, na.rm = T),

                  Sal_Y = mean (Sal_mean, na.rm = T),
                  Sal_sd = sd (Sal_mean, na.rm = T),

                  TA_Y = mean (TA_mean, na.rm = T),
                  TA_sd = sd (TA_mean, na.rm = T),

                  nTA_Y = mean (nTA_mean, na.rm = T),
                  nTA_sd = sd (nTA_mean, na.rm = T),

                  nDIC_Y = mean (nDIC_mean, na.rm = T),
                  nDIC_sd = sd (nDIC_mean, na.rm = T),

                  DIC_Y = mean (DIC_mean, na.rm = T),
                  DIC_sd = sd (DIC_mean, na.rm = T),

                  pCO2_Y = mean (pCO2_mean , na.rm = T),
                  pCO2_sd = sd (pCO2_mean , na.rm = T),

                  pH_Y = mean (pH_mean, na.rm = T),
                  pH_sd = sd (pH_mean, na.rm = T),

                  Ara_Y = mean (Ara_mean , na.rm = T),
                  Ara_sd = sd (Ara_mean , na.rm = T),
                  n())

Yearly_Stats<-Yearly_Stats %>% 
 mutate_if(is.numeric, round, digits=2)
Yearly_Stats
# write.csv(Yearly_Stats, "FLK_results/Table_1_Year_A.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

5.3 Delta months values

# 1. Get the oceanic mean values per month-year 

  WS.reef<-join(WS.reef, mean_Open_MY, 
                 type = "left", by=c("MY", "Month"))

# 2. and subtract them from the reef data
  # Delta TA
  WS.reef$dTA_MY<-WS.reef$TA_umol_kg-WS.reef$OTA_my
  # Delta DIC
  WS.reef$dDIC_MY<-WS.reef$DIC_umol_kg-WS.reef$ODIC_my
  # Delta nTA
  WS.reef$dnTA_MY<-WS.reef$n35TA-WS.reef$OnTA_my
  # Delta nDIC
  WS.reef$dnDIC_MY<-WS.reef$n35DIC-WS.reef$OnDIC_my
  # Delta pCO2
  WS.reef$dpCO2_MY<-WS.reef$pCO2_uatm-WS.reef$OpCO2_O
  # Delta pH
  WS.reef$dpH_MY<-WS.reef$pH_calculated-WS.reef$OpH_O
   # Delta Omega
  WS.reef$dOme_MY<-WS.reef$Aragonite_Sat_W-WS.reef$OAra_O
  
 # head(WS.reef)
 #summary(WS.reef$Season, digits=2)

- Delta month stats

dMonth_Stats<- ddply (WS.reef, .(Zone, Sub_region, Month2, Season, Region),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = sd (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = sd (dOme_MY , na.rm = T)#,
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  )

dMonth_Stats<-dMonth_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dMonth_Stats
#write.csv(dMonth_Stats, "FLK_results/Table_S9_Month_StatsDeltas.csv", row.names = F)

Spring.data<-WS.reef[WS.reef$Season=="Spring", ]
Summer.data<-WS.reef[WS.reef$Season=="Summer", ]
Fall.data<-WS.reef[WS.reef$Season=="Fall", ]
Winter.data<-WS.reef[WS.reef$Season=="Winter", ]

Seasonal range

Seasonal_range_d<-ddply (dMonth_Stats, .(Zone, Sub_region),
                            summarise,

                  
                  dTA_max = max (dTA_mean, na.rm = T),
                  dTA_min = min (dTA_mean, na.rm = T),
                  dTA_diff = (max (dTA_mean, na.rm = T) - min (dTA_mean, na.rm = T)),
                  
                  dDIC_max = max (dDIC_mean, na.rm = T),
                  dDIC_min = min (dDIC_mean, na.rm = T),
                  dDIC_diff = (max (dDIC_mean, na.rm = T) - min (dDIC_mean, na.rm = T)),
                  
                  dpCO2_max = max (dpCO2_mean, na.rm = T),
                  dpCO2_min = min (dpCO2_mean, na.rm = T),
                  dpCO2_dif = (max (dpCO2_mean, na.rm = T) - min (dpCO2_mean, na.rm = T)),
                  
                  dpH_max = max (dpH_mean, na.rm = T),
                  dpH_min = min (dpH_mean, na.rm = T),
                  dpH_diff = (max (dpH_mean, na.rm = T) - min (dpH_mean, na.rm = T)),
                  
                  dAra_max = max (dAra_mean, na.rm = T),
                  dAra_min = min (dAra_mean, na.rm = T),
                  dAra_diff = (max (dAra_mean, na.rm = T) - min (dAra_mean, na.rm = T)),
                  
                  n = n())

Seasonal_range_d<-Seasonal_range_d %>% 
 mutate_if(is.numeric, round, digits=3)
Seasonal_range_d
#write.csv(Seasonal_range_d, "FLK_results/Table_S8_Month_mean_range_d.csv", row.names = F)

- Delta month plots

Delta_plot<- ggplot(WS.reef) +
        MyTheme +  
        facet_grid(Sub_region~Zone)+
        scale_shape_manual(values=c(24, 25, 21))+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank())

DeltaYear_plot<- ggplot(dMonth_Stats) +
        MyTheme +  
        facet_grid(Sub_region~Region)+
        Season_fill+
        Season_colour+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              axis.text.x = element_text(angle = 10,
                                         vjust = 0.5))
        
Delta_plot_month<- ggplot(WS.reef) +
        MyTheme +  
        geom_abline(slope = 0, intercept = 0, color="grey")+
        facet_grid(~Zone)+
        guides(fill=guide_legend(override.aes=list(shape=21)))+
        scale_x_continuous(limits = c(1,12),
                     expand = c(0.05, 0.05),
                     breaks = seq(1, 12, 1),
                     name=expression(paste("Month of the year")))+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom")

DeltaYear_plot2<- ggplot(dMonth_Stats) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

DeltaYear_plot3<- ggplot(dMonth_Stats) +
        MyTheme +  
        Zone_shapes3+
        facet_grid(~Region)+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))

Frequency_plot<- ggplot(data = WS.reef) +
      geom_vline(aes(xintercept = 0), linetype = "dashed")+
      facet_grid(Zone~Sub_region, scales = "free_y")+ MyTheme

dTA

Figure Supp 4: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4A

DTA_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta,
                          "TA  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dTA_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dTA_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#DTA_exp

TA_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dTA_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dTA_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#TA_delta_Y2

dTA_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-210,70),
                     expand = c(0.03, 0.03),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dTA_mean,
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, 
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dTA_mean, colour=Sub_region),
               fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2,
               position=position_dodge(width=0.5))+
  facet_grid(~Region)
#dTA_Y3

Figure 4A: Seasonal delta Total Alkalinity (dTA) variation by region and shelf position. Mean values and 95 CI

dDIC

Figure Supp 5: Total Alkalinity (TA) variation by the region and shelf position by (A) month of the year and (B) season.

Figure 4B

dDIC_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     breaks = seq(-800, 800, 100),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dDIC_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dDIC_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))

#dDIC_exp

DIC_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    stat_summary(aes (x=Season, y=dDIC_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
  
#DIC_delta_Y2

dDIC_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-185,130),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Zone, y=dDIC_mean, 
                     fill=Sub_region, shape = Zone), 
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5,
                position=position_dodge(width=0.5))+
  stat_summary(aes (x=Zone, y=dDIC_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dDIC_Y3

Figure 4B: Seasonal delta Dissolved Inorganic Carbon (dDIC) variation by region and shelf position.

dDIC density

dDIC_freq_All<- Frequency_plot+
  geom_density(aes (dDIC_MY), fill = "lightgray", alpha=0.5) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                     expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_All

dDIC_freq_pre<- Frequency_plot+
  geom_density(aes (dDIC_MY, fill = Precipitation),
               alpha = 0.4) +
  scale_x_continuous(breaks = seq(-300, 300, 100),
                    expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
#dDIC_freq_pre

# dDIC_freq_sea<- Frequency_plot+
#   geom_density(aes (dDIC_MY, fill = Season), alpha = 0.4) +
#   scale_x_continuous(breaks = seq(-300, 300, 100),
#                      expression(paste(Delta, "DIC (", mu, "mol ", kg^-1, ")")))
# dDIC_freq_sea

dpCO2

pdCO2_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1700,2900),
                     expand = c(0.05, 0.05),
                     #breaks = seq(1800, 2800, 100),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                span=0.8, se=F)+
    stat_summary(aes (x=as.numeric(Month2),
                      y=dpCO2_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dpCO2_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))
#pdCO2_exp

pCO2_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.1, 0.1),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta ~ pCO[2] , " (", mu, "atm)")))+
    stat_summary(aes (x=Season, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))
#pCO2_delta_Y2

dPCO2_Y3<- DeltaYear_plot2+
   scale_y_continuous(#limits = c(2150,2550),
                     expand = c(0.01, 0.01),
                     #breaks = seq(0, 2500, 50),
                     name=expression(paste("")))+
    
   stat_summary(aes (x=Sub_region, y=dpCO2_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, shape=21)+
    stat_summary(aes (x=Sub_region, y=dpCO2_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
               geom = "errorbar",  width = 0.2)
#dPCO2_Y3

dpH

Figure 4C

dOmega

Figure 4D

DOmega_exp<- Delta_plot_month+
   scale_y_continuous(#limits = c(1,5.5),
                       name=(expression (paste(Delta ,
                          ~Omega[Ar]))),
                       breaks = seq(-3, 3, 0.5),
                       expand = c(0.05, 0.05)
                        ) +
  
    geom_smooth(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                span=0.8, se=F)+
      stat_summary(aes (x=as.numeric(Month2),
                      y=dOme_MY, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.2))+
    stat_summary(aes (x=as.numeric(Month2), 
                      y=dOme_MY, fill=Sub_region),
                 shape=21, size=1,
                fun.data = "mean_cl_boot", geom = "point",
                position=position_dodge(width=0.2))+
  facet_grid(Zone~.)

#DOmega_exp

om_delta_Y2<- DeltaYear_plot2+
    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.05, 0.05),
                     #breaks = seq(-800, 800, 50),
                      name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    stat_summary(aes (x=Season, y=dAra_mean, fill=Sub_region),
                fun.data = "mean_cl_boot", geom = "bar",
                position=position_dodge(width=0.8))+
    stat_summary(aes (x=Season, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", geom = "errorbar", 
                width = 0.2,
                position=position_dodge(width=0.8))+
  theme(panel.spacing = unit(0.8, "lines"))
#om_delta_Y2

dOm_Y3<- DeltaYear_plot3+
   scale_y_continuous(#limits = c(-0.9, 1),
                     expand = c(0.02, 0.02),
                     breaks = seq(-5, 5, 0.5),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    
   stat_summary(aes (x=Zone, y=dAra_mean, 
                     fill=Sub_region, shape=Zone),
                fun.data = "mean_cl_boot", geom = "point", 
                size=1.5, position=position_dodge(width=0.5))+
    stat_summary(aes (x=Zone, y=dAra_mean, colour=Sub_region),
                fun.data = "mean_cl_boot", 
                geom = "errorbar",   width = 0.2,
               position=position_dodge(width=0.5))
#dOm_Y3

- Figure 4: Seasonal Δ and yearly sums

Seasonality_deltas<-ggarrange(
          TA_delta_Y2 +theme(legend.position = "none",
                              axis.text.x=element_blank()),
          DIC_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          pH_delta_Y2+theme(legend.position = "none",
                              strip.text.x = element_blank(),
                              axis.text.x=element_blank()), 
          om_delta_Y2+ theme(panel.spacing = unit(0.8, "lines"),
                              strip.text.x = element_blank()),
          #TA_DIC_sum,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1.2))
          #widths = c(1, 1, 0.9))
Seasonality_deltas

Seasonality_deltas3<-ggarrange(
          dTA_my3,
          dDIC_my3,
          dpH_my3,
          dOm_my3,
          nrow = 4, 
          #labels = c("A", "B", " C"),
          heights =c(1, 0.9, 0.9, 1))
Seasonality_deltas3

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_season.svg", plot=Seasonality_deltas, dpi = 300, width=6, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_ICRS.svg", plot=Seasonality_deltas, dpi = 300, width=8, height=6)

#ggsave(file="FLK_results/Figures/Fig_4/Fig_4_delta_Summary.svg", plot=Seasonality_deltas3, dpi = 300, width=8, height=8)

Figure 4: Seasonal inshore-ocean gradients in the Florida Keys. (A) Seasonal ΔTA. (B) Seasonal ΔDIC. (C) Seasonal ΩAr. The bars represent the mean Δ values per season, region, and shelf position (± 95 CI).

5.4 Delta season values

- Delta season stats (all data)

  dSeason_Stats<- ddply (WS.reef, .(Zone, Sub_region, Season),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  
                  #dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  #dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  #dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  n())

dSeason_Stats<-dSeason_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dSeason_Stats

- Delta season stats (monthly mean)

dSeasonal_Stats2<- ddply (dMonth_Stats,
                          .(Zone, Season, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  #dnTA_M = mean (dnTA_mean, na.rm = T),
                  #dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  #dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  #dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dSeasonal_Stats2<-dSeasonal_Stats2 %>% 
 mutate_if(is.numeric, round, digits=3)
dSeasonal_Stats2
#write.csv(dSeasonal_Stats2, "FLK_results/Table_2_SeasonDelta_B.csv", row.names = F)

Note: SD is NA when calculating it based on monthly meand (n=3 per season)

- Delta yearly stats (monthly mean)

dYearly_Stats<- ddply (dMonth_Stats, .(Zone, Sub_region),
                         summarise,

                  dTA_M = mean (dTA_mean, na.rm = T),
                  dTA_sd = sd (dTA_mean, na.rm = T),
                  #dTA_se = std.error (dTA_mean, na.rm = T),
                  
                  dDIC_M = mean (dDIC_mean, na.rm = T),
                  dDIC_sd = sd (dDIC_mean, na.rm = T),
                  #dDIC_se = std.error (dDIC_mean, na.rm = T),
                  
                  dnTA_M = mean (dnTA_mean, na.rm = T),
                  dnTA_sd = sd (dnTA_mean, na.rm = T),
                  
                  dnDIC_M = mean (dnDIC_mean, na.rm = T),
                  dnDIC_sd = sd (dnDIC_mean, na.rm = T),

                  dpCO2_M = mean (dpCO2_mean , na.rm = T),
                  dpCO2_sd = sd (dpCO2_mean , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_mean , na.rm = T),

                  dpH_M = mean (dpH_mean, na.rm = T),
                  dpH_sd = sd (dpH_mean, na.rm = T),
                  #dpH_se = std.error (dpH_mean, na.rm = T),

                  dAra_M = mean (dAra_mean , na.rm = T),
                  dAra_sd = sd (dAra_mean , na.rm = T),
                  #dAra_se = std.error (dAra_mean , na.rm = T),
                  n())

dYearly_Stats<-dYearly_Stats %>% 
 mutate_if(is.numeric, round, digits=3)
dYearly_Stats
#write.csv(dYearly_Stats, "FLK_results/Table_1b_delta_year.csv", row.names = F)

- Yearly summ (monthly mean)

dYear_Add<- ddply (dMonth_Stats, .(Zone, Sub_region),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add<-dYear_Add %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add
#write.csv(dYear_Add, "FLK_results/Table_1_year_byMM.csv", row.names = F)

- Yearly summ (indiviual years)

dYear_Add2<- ddply (WS.reef, .(Zone, Sub_region, MY, Region, Year),
                            summarise,
                  dTA_mean = mean (dTA_MY, na.rm = T),
                  dTA_sd = sd (dTA_MY, na.rm = T),
                  #dTA_se = std.error (dTA_MY, na.rm = T),
                  
                  dnTA_mean = mean (dnTA_MY, na.rm = T),
                  dnTA_sd = sd (dnTA_MY, na.rm = T),
                 
                  dDIC_mean = mean (dDIC_MY, na.rm = T),
                  dDIC_sd = mean (dDIC_MY, na.rm = T),
                  #dDIC_se = std.error (dDIC_MY, na.rm = T),
                  
                  dnDIC_mean = mean (dnDIC_MY, na.rm = T),
                  dnDIC_sd = sd (dnDIC_MY, na.rm = T),
                  
                  dpCO2_mean = mean (dpCO2_MY , na.rm = T),
                  dpCO2_sd = sd (dpCO2_MY , na.rm = T),
                  #dpCO2_se = std.error (dpCO2_MY, na.rm = T),
                  
                  dpH_mean = mean (dpH_MY, na.rm = T),
                  dpH_sd = mean (dpH_MY, na.rm = T),
                  #dPH_se = std.error (dpH_MY, na.rm = T),
                  
                  dAra_mean = mean (dOme_MY , na.rm = T),
                  dAra_sd = mean (dOme_MY , na.rm = T),
                  #dAra_se = std.error (dOme_MY, na.rm = T),
                  n())

dYear_Add2<-dYear_Add2 %>% 
 mutate_if(is.numeric, round, digits=3)
dYear_Add2
dYear_Add2<-dYear_Add2[dYear_Add2$Year>2014, ]
dYear_Add2<-dYear_Add2[dYear_Add2$Year<2022, ]

dYear_Add3<- ddply (dYear_Add2, .(Zone, Sub_region, Year),
           summarise,
  su_dTA_Y = sum (dTA_mean, na.rm = T),
  #m_TA_Y = mean (dTA_mean, na.rm = T),
  #sd_TA_Y = sd (dTA_mean, na.rm = T),
  
  su_dDIC_Y = sum (dDIC_mean, na.rm = T),
  #m_dDIC_Y = mean (dDIC_mean, na.rm = T),
  #sd_dDIC_Y = sd (dDIC_mean, na.rm = T),
  

  su_dpCO2_Y = sum (dpCO2_mean, na.rm = T),
  #m_pCO2_Y = mean (dpCO2_mean, na.rm = T),
  #sd_pCO2_Y = sd (dpCO2_mean, na.rm = T),
  
  su_dpH_Y = sum (dpH_mean, na.rm = T),
  #m_pH_Y = mean (dpH_mean, na.rm = T),
  #sd_pH_Y = sd (dpH_mean, na.rm = T),
  
  su_dAra_Y = sum (dAra_mean, na.rm = T),
  #m_Ara_Y = mean (dAra_mean, na.rm = T),
  #sd_Ara_Y = sd (dAra_mean, na.rm = T),
  n())

dYear_Add3<-dYear_Add3 %>% 
 mutate_if(is.numeric, round, digits=2)
dYear_Add3

5.5 Seasoal models

season.data<-WS.reef[WS.reef$Extreme=="Normal", ]
season.data<-droplevels(season.data)
season.data$Zone<-factor(season.data$Zone, levels = c("Offshore", "Mid channel", "Inshore"))
#summary(season.data)

inshore.season.data<-season.data[season.data$Zone=="Inshore", ]
midchanel.season.data<-season.data[season.data$Zone=="Mid channel", ]
ofshore.season.data<-season.data[season.data$Zone=="Offshore", ]

LMER - TA month

  hist(FLK.data_filtered$TA_umol_kg)

  shapiro.test(FLK.data_filtered$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  FLK.data_filtered$TA_umol_kg
## W = 0.81083, p-value < 2.2e-16
# 
#   dTA_seson<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_month_0<-lmer(TA_umol_kg~  Zone * Sub_region * Month +
                           (1|SiteID), data=FLK.data_filtered)
  #anova(TA_month_0)
  
  TA_month<-lmer(TA_umol_kg~  Zone + Sub_region + Month +
                              Zone:Sub_region + Zone:Month + Sub_region:Month +
                              (1|SiteID), data=season.data)
  
  #summary(dTA_seson)    
  av.TA_month<-(anova(TA_month))
  av.TA_month
  ranova(TA_month)
  #step(TA_month)
  
  plot(TA_month)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_month))
  acf(resid(TA_month), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(TA_month, scale = TRUE)
  #plot_summs(TA_month)
  
  TA_mo.emmc<-emmeans(TA_month, ~Zone*Month, by="Sub_region")
    TA_mon.emmc<-multcomp::cld(TA_mo.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    #TA_mon.emmc<-TA_mon.emmc[order(TA_mon.emmc$Zone, TA_mon.emmc$Month), ]
  TA_mon.emmc

LMER - TA season

  hist(season.data$TA_umol_kg)

  shapiro.test(season.data$TA_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$TA_umol_kg
## W = 0.84003, p-value < 2.2e-16
# 
#   dTA_seson<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  TA_season_0<-lmer(TA_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  anova(TA_season_0)
  TA_season<-lmer(TA_umol_kg~  Zone + Sub_region + Season +
                              Zone:Sub_region + Zone:Season + Sub_region:Season +
                              (1|SiteID), data=season.data)
  anova(TA_season_0, TA_season)
  #summary(av.TA_season)    
  av.TA_season<-(anova(TA_season))
  av.TA_season
  ranova(TA_season)
  #step(TA_season)
  
  plot(TA_season)

  par(mfrow=c(1,2))
  qqnorm(resid(TA_season))
  acf(resid(TA_season), main="acf(resid(TA Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(TA_season)
  
  TA_se.emmc<-emmeans(TA_season, ~Zone*Season, by="Sub_region")
    TA_seas.emmc<-multcomp::cld(TA_se.emmc)
    TA_seas.emmc
  TA_se.emmc2<-emmeans(TA_season, ~Sub_region*Season, by="Zone")
    TA_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    TA_seas.emmc2

LMER - all dTA - MODEL 13

  hist(season.data$dTA_MY)

  shapiro.test(season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dTA_MY
## W = 0.81295, p-value < 2.2e-16
# 
#   dTA_seson<-lmer(dTA_MY~  Zone + Sub_region + Season +
#                            Zone:Sub_region + Zone:Season + Sub_region:Season+   
#                            (1|SiteID), data=season.data)
  
  dTA_seson<-lmer(dTA_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dTA_seson)    
  av.dTA_seson<-(anova(dTA_seson))
  av.dTA_seson
  ranova(dTA_seson)
  #step(dTA_seson)
  
  plot(dTA_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_seson))
  acf(resid(dTA_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  
  #summ(dTA_seson, scale = TRUE)
  #plot_summs(dTA_seson)
 dTA_ses.emmc<-emmeans(dTA_seson, ~Season*Sub_region, by="Zone")
    dTA_ses.emmc<-multcomp::cld(dTA_ses.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_ses.emmc<-dTA_ses.emmc[order(dTA_ses.emmc$Zone, 
                                     dTA_ses.emmc$Season, 
                                     dTA_ses.emmc$Sub_region), ]
  dTA_ses.emmc
  dTA_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dTA
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 1.05 11.86 242.13 -22.33 24.42 1
Winter UK 3.89 10.17 278.88 -16.13 23.91 1
Winter MK 4.60 9.78 249.88 -14.66 23.85 1
Winter LK 1.95 8.39 239.51 -14.59 18.48 1
Spring BB -3.90 11.28 199.06 -26.15 18.35 1
Spring UK -1.98 9.60 233.02 -20.91 16.94 1
Spring MK -7.46 8.86 176.87 -24.94 10.02 1
Spring LK -11.49 7.62 170.97 -26.52 3.55 1
Summer BB -4.71 11.01 186.94 -26.43 17.01 1
Summer UK -5.37 9.28 207.21 -23.67 12.93 1
Summer MK -21.53 8.99 186.94 -39.26 -3.79 1
Summer LK -10.34 7.79 186.94 -25.69 5.02 1
Fall BB -0.04 10.55 158.72 -20.87 20.79 1
Fall UK -1.47 9.13 197.13 -19.47 16.54 1
Fall MK -1.23 8.49 151.90 -18.01 15.55 1
Fall LK -3.36 7.38 153.29 -17.94 11.23 1
Mid-Channel
Winter BB 8.02 12.20 267.02 -16.00 32.04 34
Winter UK 10.66 12.57 293.82 -14.09 35.40 34
Winter MK 25.23 9.78 249.88 5.98 44.49 4
Winter LK 13.54 8.99 185.97 -4.20 31.28 4
Spring BB -8.62 12.21 263.60 -32.66 15.42 234
Spring UK -3.02 11.86 242.08 -26.40 20.35 234
Spring MK -37.31 8.73 167.88 -54.54 -20.07 123
Spring LK -49.12 8.49 151.91 -65.90 -32.33 12
Summer BB -11.51 11.01 186.94 -33.23 10.21 234
Summer UK -7.34 11.56 219.31 -30.13 15.44 234
Summer MK -61.62 8.99 186.94 -79.36 -43.89 1
Summer LK -67.34 8.99 186.94 -85.07 -49.60 1
Fall BB 4.02 10.77 172.23 -17.23 25.28 34
Fall UK 0.48 11.27 202.70 -21.74 22.71 34
Fall MK 6.05 8.61 159.82 -10.96 23.05 4
Fall LK -11.15 8.28 138.33 -27.52 5.22 234
Inshore
Winter BB 40.60 11.86 242.13 17.23 63.97 56
Winter UK 48.74 10.61 323.46 27.87 69.60 56
Winter MK 57.00 10.38 304.17 36.58 77.41 6
Winter LK 7.31 9.29 206.24 -10.99 25.62 45
Spring BB -62.58 11.28 199.10 -84.83 -40.32 23
Spring UK -57.07 9.96 267.02 -76.68 -37.46 23
Spring MK -80.92 8.49 151.90 -97.70 -64.14 2
Spring LK -124.51 8.38 144.78 -141.08 -107.94 1
Summer BB -37.62 11.01 186.94 -59.34 -15.90 234
Summer UK -33.41 9.60 233.02 -52.33 -14.49 34
Summer MK -122.12 9.13 197.16 -140.13 -104.11 1
Summer LK -157.07 9.28 208.69 -175.36 -138.78 1
Fall BB 23.38 10.34 148.24 2.96 43.80 56
Fall UK 43.60 9.43 221.70 25.00 62.19 56
Fall MK 14.54 8.61 159.09 -2.46 31.55 56
Fall LK -60.08 8.28 138.33 -76.45 -43.71 23
  dTA_year.emmc<-emmeans(dTA_seson, ~Sub_region*Zone)
    dTA_year.emmc<-multcomp::cld(dTA_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dTA_year.emmc<-dTA_year.emmc[order(dTA_year.emmc$Zone, 
                                      dTA_year.emmc$Sub_region), ]
  #dTA_year.emmc
  
  dTA_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dTA") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dTA
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -1.90 6.27 21.01 -14.94 11.14 34
UK -1.23 5.31 24.32 -12.18 9.71 4
MK -6.40 5.08 20.44 -16.98 4.17 34
LK -5.81 4.38 20.16 -14.95 3.34 34
Mid-Channel
BB -2.02 6.44 23.46 -15.32 11.28 34
UK 0.19 6.55 25.21 -13.30 13.69 34
MK -16.91 5.07 20.41 -27.48 -6.34 234
LK -28.52 4.92 18.07 -38.85 -18.18 23
Inshore
BB -9.06 6.25 20.74 -22.06 3.95 234
UK 0.46 5.47 27.42 -10.75 11.67 4
MK -32.88 5.14 21.47 -43.55 -22.20 2
LK -83.59 4.98 18.86 -94.01 -73.16 1

Figure 4A: Model

dTA_ses_2.emmc<-as.data.frame(dTA_ses.emmc)
dTA_ye_3.emmc<-as.data.frame(dTA_year.emmc)
dTA_ye_3.emmc$Season<-"Mean"

dTA_all_4<-rbind(dTA_ses_2.emmc, dTA_ye_3.emmc)
dTA_all_4$Zone<-factor(dTA_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearTA<- ggplot(dTA_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "TA  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearTA

LMER - dTA Inshore

# Inshore dTA
  hist(inshore.season.data$dTA_MY)

  shapiro.test(inshore.season.data$dTA_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dTA_MY
## W = 0.96669, p-value = 3.329e-08
  dTA_seson_in<-lmer(dTA_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dTA_seson_in)    
  av.dTA_seson_in<-anova(dTA_seson_in)
  av.dTA_seson_in
  ranova(dTA_seson_in)
  #step(dTA_seson_in)
  
  plot(dTA_seson_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dTA_seson_in))
  acf(resid(dTA_seson_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dTA_seson_in, scale = TRUE)
  #plot_summs(dTA_seson_in)
  
  dTA_ses_in.emmc<-emmeans(dTA_seson_in, ~ Sub_region*Season)
    dTA_ses_in.emmc<-multcomp::cld(dTA_ses_in.emmc)
    #dTA_ses_in.emmc<-as.data.frame(dTA_ses_in.emmc[complete.cases(dTA_ses_in.emmc),])
    dTA_ses_in.emmc<-dTA_ses_in.emmc[order(dTA_ses_in.emmc$Season,
                                           dTA_ses_in.emmc$Sub_region), ]
  dTA_ses_in.emmc

LMER - DIC season

  hist(season.data$DIC_umol_kg)

  shapiro.test(season.data$DIC_umol_kg) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$DIC_umol_kg
## W = 0.92541, p-value < 2.2e-16
  DIC_season_0<-lmer(DIC_umol_kg~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  

  #summary(DIC_season_0)    
  av.DIC_season<-(anova(DIC_season_0))
  av.DIC_season
  ranova(DIC_season_0)
  #step(DIC_season_0)
  
  plot(DIC_season_0)

  par(mfrow=c(1,2))
  qqnorm(resid(DIC_season_0))
  acf(resid(DIC_season_0), main="acf(resid(DIC Season))")

  par(mfrow=c(1,1))
  
  #summ(av.TA_season, scale = TRUE)
  #plot_summs(av.DIC_season)
  
  DIC_se.emmc<-emmeans(DIC_season_0, ~Zone*Season, by="Sub_region")
    DIC_seas.emmc<-multcomp::cld(DIC_se.emmc)
    DIC_seas.emmc
  DIC_se.emmc2<-emmeans(DIC_season_0, ~Sub_region*Season, by="Zone")
    DIC_seas.emmc2<-multcomp::cld(TA_se.emmc2)
    DIC_seas.emmc2

LMER - all dDIC - MODEL 14

# Inshore Omega
  hist(season.data$dDIC_MY)

  shapiro.test(season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dDIC_MY
## W = 0.87049, p-value < 2.2e-16
  # dDIC_seson<-lmer(dDIC_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  
  dDIC_seson<-lmer(dDIC_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dDIC_seson)    
  av.dDIC_seson<-anova(dDIC_seson)
  av.dDIC_seson
  ranova(dDIC_seson)
  step(dDIC_seson)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC   LRT Df Pr(>Chisq)  
## <none>                    50 -6573.3 13247                      
## (1 | SiteID)          0   49 -6576.0 13250 5.426  1    0.01984 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF DenDF F value   Pr(>F)
## Zone:Sub_region:Season          0  94802  5266.8    18  1208  2.2734 0.001778
##                          
## Zone:Sub_region:Season **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Zone * Sub_region * Season + (1 | SiteID)
  plot(dDIC_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(dDIC_seson))
  acf(resid(dDIC_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_seson, scale = TRUE)
  #plot_summs(dDIC_seson)
  
 dDIC_ses.emmc<-emmeans(dDIC_seson, ~Season*Sub_region, by="Zone")
    dDIC_ses.emmc<-multcomp::cld(dDIC_ses.emmc)
    #dDIC_ses.emmc<-as.data.frame(dDIC_ses.emmc[complete.cases(dDIC_ses.emmc),])
    dDIC_ses.emmc<-dDIC_ses.emmc[order(dDIC_ses.emmc$Zone, 
                                     dDIC_ses.emmc$Season, 
                                     dDIC_ses.emmc$Sub_region), ]
  #dDIC_ses.emmc

  dDIC_ses.emmc[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal dDIC
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB -1.15 12.72 167.12 -26.27 23.96 1
Winter UK -0.10 10.86 193.67 -21.52 21.33 1
Winter MK 7.93 10.47 172.29 -12.74 28.61 1
Winter LK 7.33 8.79 152.28 -10.04 24.70 1
Spring BB -0.53 12.16 139.83 -24.57 23.51 1
Spring UK -1.51 10.31 161.61 -21.86 18.85 1
Spring MK -13.60 9.58 123.97 -32.56 5.36 1
Spring LK -6.06 8.25 120.59 -22.39 10.27 1
Summer BB 4.53 11.89 130.44 -18.99 28.05 1
Summer UK -3.19 9.99 144.36 -22.94 16.56 1
Summer MK -17.56 9.71 130.44 -36.77 1.64 1
Summer LK 0.38 8.68 146.89 -16.78 17.54 1
Fall BB 3.67 11.44 112.44 -19.00 26.34 1
Fall UK 2.40 9.84 137.26 -17.07 21.86 1
Fall MK 0.53 9.23 107.70 -17.76 18.82 1
Fall LK 1.48 8.02 108.77 -14.42 17.37 1
Mid-Channel
Winter BB 10.65 13.05 183.59 -15.10 36.40 45
Winter UK 1.73 13.42 202.15 -24.73 28.19 2345
Winter MK 24.47 10.47 172.29 3.79 45.14 45
Winter LK 31.80 9.71 130.16 12.59 51.01 5
Spring BB -21.87 13.06 182.44 -47.64 3.90 12345
Spring UK -29.06 12.72 167.09 -54.17 -3.94 1234
Spring MK -65.70 9.46 118.11 -84.43 -46.98 1
Spring LK -53.49 9.23 107.70 -71.79 -35.20 12
Summer BB 7.50 11.89 130.44 -16.02 31.02 45
Summer UK 0.65 12.43 152.51 -23.90 25.20 345
Summer MK -50.88 9.71 130.44 -70.08 -31.67 123
Summer LK -50.57 9.99 144.87 -70.31 -30.83 123
Fall BB 21.21 11.66 120.96 -1.87 44.29 45
Fall UK 16.04 12.14 140.95 -7.97 40.05 45
Fall MK 21.28 9.34 112.77 2.77 39.78 45
Fall LK 4.84 9.02 98.82 -13.06 22.74 45
Inshore
Winter BB 46.89 12.72 167.13 21.78 72.01 3456
Winter UK 43.08 11.29 223.41 20.83 65.33 345
Winter MK 55.51 11.06 209.23 33.71 77.32 56
Winter LK 27.89 10.00 144.14 8.13 47.65 2345
Spring BB -90.89 12.16 139.85 -114.93 -66.84 1
Spring UK -125.12 10.66 183.59 -146.14 -104.10 1
Spring MK -130.40 9.23 107.70 -148.69 -112.11 1
Spring LK -131.65 9.12 103.07 -149.75 -113.56 1
Summer BB -1.40 11.89 130.44 -24.92 22.12 234
Summer UK -22.08 10.31 161.61 -42.44 -1.73 2
Summer MK -98.54 9.84 137.28 -118.00 -79.07 1
Summer LK -95.74 10.30 162.27 -116.08 -75.39 1
Fall BB 69.20 11.24 105.33 46.92 91.48 56
Fall UK 93.76 10.14 153.31 73.73 113.79 6
Fall MK 47.65 9.34 112.55 29.14 66.16 456
Fall LK -6.04 9.02 98.82 -23.94 11.86 23
  dDIC_year.emmc<-emmeans(dDIC_seson, ~Sub_region*Zone)
    dDIC_year.emmc<-multcomp::cld(dDIC_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dDIC_year.emmc<-dDIC_year.emmc[order(dDIC_year.emmc$Zone, 
                                      dDIC_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dDIC_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year dDIC") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year dDIC
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 1.63 7.45 20.91 -13.88 17.13 23
UK -0.60 6.25 23.31 -13.52 12.32 23
MK -5.68 6.05 20.45 -18.27 6.92 23
LK 0.78 5.23 20.35 -10.13 11.69 3
Mid-Channel
BB 4.37 7.60 22.67 -11.36 20.11 3
UK -2.66 7.71 23.94 -18.57 13.25 23
MK -17.71 6.05 20.43 -30.30 -5.12 23
LK -16.86 5.94 19.05 -29.29 -4.42 23
Inshore
BB 5.95 7.43 20.70 -9.52 21.43 3
UK -2.59 6.40 25.54 -15.75 10.57 23
MK -31.44 6.10 21.21 -44.13 -18.76 12
LK -51.39 5.99 19.73 -63.90 -38.87 1

Figure 4B: Model

dDIC_ses_2.emmc<-as.data.frame(dDIC_ses.emmc)
dDIC_ye_3.emmc<-as.data.frame(dDIC_year.emmc)
dDIC_ye_3.emmc$Season<-"Mean"

dDIC_all_4<-rbind(dDIC_ses_2.emmc, dDIC_ye_3.emmc)
dDIC_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearDIC<- ggplot(dDIC_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     #breaks = seq(-800, 800, 50),
                     name=expression(paste(Delta, "DIC  (", mu, "mol ", ~kg^-1, ")")))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 
DeltaYearDIC

LMER - dDIC Inshore

# Inshore dDIC
  hist(inshore.season.data$dDIC_MY)

  shapiro.test(inshore.season.data$dDIC_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dDIC_MY
## W = 0.99236, p-value = 0.03032
  dDIC_seson_in<-lmer(dDIC_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dDIC_seson_in)    
  av.dDIC_seson_in<-anova(dDIC_seson_in)
  av.dDIC_seson_in
  ranova(dDIC_seson_in)
  #step(dDIC_seson_in)
  
  plot(dDIC_seson_in)

  par(mfrow=c(1,1))
  qqnorm(resid(dDIC_seson_in))

  acf(resid(dDIC_seson_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dDIC_seson_in, scale = TRUE)
  #plot_summs(dDIC_seson_in)
  
  dDIC_ses_in.emmc<-emmeans(dDIC_seson_in, ~ Sub_region*Season)
    dDIC_ses_in.emmc<-multcomp::cld(dDIC_ses_in.emmc)
    #dDIC_ses_in.emmc<-as.data.frame(dDIC_ses_in.emmc[complete.cases(dDIC_ses_in.emmc),])
    dDIC_ses_in.emmc<-dDIC_ses_in.emmc[order(dDIC_ses_in.emmc$Season,
                                           dDIC_ses_in.emmc$Sub_region), ]
  dDIC_ses_in.emmc

LMER - all dpCO2

# Inshore Omega
  hist(season.data$dpCO2_MY)

  shapiro.test(season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpCO2_MY
## W = 0.91083, p-value < 2.2e-16
  # dpCO2_seson<-lmer(dpCO2_MY~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpCO2_seson<-lmer(dpCO2_MY~ Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpCO2_seson)    
  av.dPCO2_seson<-anova(dpCO2_seson)
  av.dPCO2_seson
  ranova(dpCO2_seson)
  step(dpCO2_seson)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik   AIC    LRT Df Pr(>Chisq)  
## <none>                    50 -6588.2 13276                       
## (1 | SiteID)          0   49 -6591.3 13281 6.2747  1    0.01225 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                        Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)
## Zone:Sub_region:Season          1  59111    3284    18 1204.5  1.3615 0.1417094
## Zone:Sub_region                 2  13233    2206     6   21.3  0.9096 0.5067938
## Zone:Season                     0 599447   99908     6 1224.1 41.2105 < 2.2e-16
## Sub_region:Season               0  68374    7597     9 1223.3  3.1337 0.0009677
##                           
## Zone:Sub_region:Season    
## Zone:Sub_region           
## Zone:Season            ***
## Sub_region:Season      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dpCO2_MY ~ Zone + Sub_region + Season + (1 | SiteID) + Zone:Season + Sub_region:Season
  plot(dpCO2_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_seson))
  acf(resid(dpCO2_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpCO2_seson)  
  
  dpCO2_ses.emmc<-emmeans(dpCO2_seson, ~Zone*Sub_region*Season)
    dpCO2_ses.emmc<-multcomp::cld(dpCO2_ses.emmc)
    #dpCO2_ses.emmc<-as.data.frame(dpCO2_ses.emmc[complete.cases(dpCO2_ses.emmc),])
    dpCO2_ses.emmc<-dpCO2_ses.emmc[order(dpCO2_ses.emmc$Zone, dpCO2_ses.emmc$Season), ]
  dpCO2_ses.emmc
  #summ(dpCO2_seson, scale = TRUE)

LMER - dPCO2 Inshore

# Inshore dDIC
  hist(inshore.season.data$dpCO2_MY)

  shapiro.test(inshore.season.data$dpCO2_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$dpCO2_MY
## W = 0.98434, p-value = 0.0001655
  dpCO2_seson_in<-lmer(dpCO2_MY~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
  #summary(dpCO2_seson_in)    
  av.dPCO2_seson_in<-anova(dpCO2_seson_in)
  av.dPCO2_seson_in
  ranova(dpCO2_seson_in)
  #step(dpCO2_seson_in)
  
  plot(dpCO2_seson_in)

  par(mfrow=c(1,2))
  qqnorm(resid(dpCO2_seson_in))
  acf(resid(dpCO2_seson_in), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #summ(dpCO2_seson_in, scale = TRUE)
  #plot_summs(dpCO2_seson_in)
  
  dpCO2_ses_in.emmc<-emmeans(dpCO2_seson_in, ~ Sub_region*Season)
    dpCO2_ses_in.emmc<-multcomp::cld(dpCO2_ses_in.emmc)
    #dpCO2_ses_in.emmc<-as.data.frame(dpCO2_ses_in.emmc[complete.cases(dpCO2_ses_in.emmc),])
    dpCO2_ses_in.emmc<-dpCO2_ses_in.emmc[order(dpCO2_ses_in.emmc$Season,
                                           dpCO2_ses_in.emmc$Sub_region), ]
  dpCO2_ses_in.emmc

LMER - all Omega

# Inshore Omega
  hist(season.data$Aragonite_Sat_W)

  shapiro.test(season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$Aragonite_Sat_W
## W = 0.98017, p-value = 2.733e-12
  # Omega_seson<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  Omega_seson<-lmer(Aragonite_Sat_W~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(Omega_seson)    
  av.Ome_seson<-anova(Omega_seson)
  av.Ome_seson
  ranova(Omega_seson)
  #step(Omega_seson)
  
  plot(Omega_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(Omega_seson))
  acf(resid(Omega_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(Omega_seson)  
    
  # Ara_ses.emmc<-emmeans(Omega_seson, ~Zone*Sub_region*Season)
  #   Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
  #   Ara_ses.emmc<-as.data.frame(Ara_ses.emmc[complete.cases(Ara_ses.emmc),])
  #   Ara_ses.emmc<-Ara_ses.emmc[order(Ara_ses.emmc$Zone, Ara_ses.emmc$Season), ]
  # Ara_ses.emmc
  
  Ara_ses.emmc<-emmeans(Omega_seson, ~Zone*Season, by="Sub_region")
    Ara_ses.emmc<-multcomp::cld(Ara_ses.emmc)
    Ara_ses.emmc
  Ara_ses.emmc2<-emmeans(Omega_seson, ~Sub_region*Season, by="Zone")
    Ara_ses.emmc2<-multcomp::cld(Ara_ses.emmc2)
    Ara_ses.emmc2

LMER - all dOmega - MODEL 16

# Inshore Omega
  hist(season.data$dOme_MY)

  shapiro.test(season.data$dOme_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dOme_MY
## W = 0.94515, p-value < 2.2e-16
  # Omega_seson<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dOmega_seson<-lmer(dOme_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dOmega_seson)    
  av.dOme_seson<-anova(dOmega_seson)
  av.dOme_seson
  ranova(dOmega_seson)
  #step(dOmega_seson)
  
  plot(dOmega_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(dOmega_seson))
  acf(resid(dOmega_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dOmega_seson)  
    
dAra_ses.emmc<-emmeans(dOmega_seson, ~Zone*Season, by="Sub_region")
    dAra_ses.emmc<-multcomp::cld(dAra_ses.emmc)
    dAra_ses.emmc
dAra_ses.emmc1<-emmeans(dOmega_seson, ~Sub_region*Season, by="Zone")
    dAra_ses.emmc1<-multcomp::cld(dAra_ses.emmc1)
    dAra_ses.emmc1
dAra_ses.emmc2<-emmeans(dOmega_seson, ~Season*Sub_region, by="Zone")
    dAra_ses.emmc2<-multcomp::cld(dAra_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dAra_ses.emmc2<-dAra_ses.emmc2[order(dAra_ses.emmc2$Zone, 
                                     dAra_ses.emmc2$Season, 
                                     dAra_ses.emmc2$Sub_region), ]

dAra_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                 caption = "Seasonal d Omega") %>%
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d Omega
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.02 0.07 224.53 -0.12 0.16 1
Winter UK 0.04 0.06 259.15 -0.08 0.16 1
Winter MK -0.04 0.06 231.70 -0.16 0.07 1
Winter LK -0.07 0.05 222.35 -0.17 0.03 1
Spring BB -0.04 0.07 185.12 -0.17 0.10 1
Spring UK -0.01 0.06 216.27 -0.12 0.11 1
Spring MK 0.06 0.05 164.28 -0.04 0.17 1
Spring LK -0.06 0.05 158.98 -0.15 0.03 1
Summer BB -0.10 0.07 173.51 -0.23 0.03 1
Summer UK -0.03 0.06 192.38 -0.14 0.08 1
Summer MK -0.06 0.05 173.51 -0.17 0.04 1
Summer LK -0.14 0.05 196.45 -0.24 -0.05 1
Fall BB -0.04 0.06 147.68 -0.17 0.08 1
Fall UK -0.05 0.05 182.94 -0.15 0.06 1
Fall MK -0.02 0.05 141.32 -0.12 0.08 1
Fall LK -0.06 0.04 142.64 -0.15 0.03 1
Mid-Channel
Winter BB -0.04 0.07 247.53 -0.19 0.10 1234
Winter UK 0.08 0.08 272.55 -0.07 0.23 2345
Winter MK 0.00 0.06 231.70 -0.12 0.11 1234
Winter LK -0.19 0.05 172.72 -0.29 -0.08 12
Spring BB 0.13 0.07 244.70 -0.01 0.28 345
Spring UK 0.27 0.07 224.49 0.13 0.41 45
Spring MK 0.27 0.05 156.01 0.17 0.37 5
Spring LK 0.02 0.05 141.32 -0.08 0.12 2345
Summer BB -0.22 0.07 173.51 -0.35 -0.09 12
Summer UK -0.09 0.07 203.59 -0.22 0.05 123
Summer MK -0.16 0.05 173.51 -0.27 -0.05 123
Summer LK -0.27 0.06 193.60 -0.38 -0.16 1
Fall BB -0.19 0.06 160.01 -0.32 -0.06 12
Fall UK -0.17 0.07 188.09 -0.30 -0.04 123
Fall MK -0.17 0.05 148.58 -0.27 -0.07 123
Fall LK -0.18 0.05 128.83 -0.28 -0.09 12
Inshore
Winter BB -0.06 0.07 224.53 -0.20 0.08 456
Winter UK 0.05 0.06 300.45 -0.08 0.17 56
Winter MK 0.03 0.06 282.20 -0.09 0.15 56
Winter LK -0.24 0.06 191.59 -0.35 -0.13 2345
Spring BB 0.24 0.07 185.16 0.11 0.37 67
Spring UK 0.65 0.06 247.53 0.53 0.77 8
Spring MK 0.44 0.05 141.32 0.34 0.55 78
Spring LK -0.01 0.05 134.77 -0.11 0.09 56
Summer BB -0.41 0.07 173.51 -0.54 -0.28 123
Summer UK -0.13 0.06 216.26 -0.25 -0.02 345
Summer MK -0.36 0.05 182.97 -0.47 -0.25 234
Summer LK -0.67 0.06 217.83 -0.78 -0.55 1
Fall BB -0.48 0.06 137.96 -0.60 -0.35 12
Fall UK -0.51 0.06 205.56 -0.62 -0.40 12
Fall MK -0.35 0.05 147.98 -0.45 -0.25 234
Fall LK -0.63 0.05 128.83 -0.73 -0.53 1
dOm_year.emmc<-emmeans(dOmega_seson, ~Sub_region*Zone)
    dOm_year.emmc<-multcomp::cld(dOm_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dOm_year.emmc<-dOm_year.emmc[order(dOm_year.emmc$Zone, 
                                      dOm_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dOm_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d Omega") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d Omega
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB -0.04 0.04 20.83 -0.12 0.04 23
UK -0.01 0.03 23.93 -0.08 0.06 23
MK -0.02 0.03 20.28 -0.08 0.05 23
LK -0.08 0.03 20.57 -0.14 -0.03 23
Mid-Channel
BB -0.08 0.04 23.12 -0.16 0.00 23
UK 0.02 0.04 24.76 -0.06 0.10 23
MK -0.02 0.03 20.26 -0.08 0.05 23
LK -0.16 0.03 18.52 -0.22 -0.09 2
Inshore
BB -0.18 0.04 20.58 -0.26 -0.10 2
UK 0.01 0.03 26.82 -0.05 0.08 3
MK -0.06 0.03 21.25 -0.13 0.00 23
LK -0.39 0.03 19.36 -0.45 -0.32 1

Figure 4D: Model

dAra_ses_2.emmc<-as.data.frame(dAra_ses.emmc2)
dAra_ye_3.emmc<-as.data.frame(dOm_year.emmc)
dAra_ye_3.emmc$Season<-"Mean"

dAra_all_4<-rbind(dAra_ses_2.emmc, dAra_ye_3.emmc)
dAra_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearAra<- ggplot(dAra_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.03, 0.03),
                     breaks = seq(-6, 6, 0.3),
                     name=(expression (paste(Delta ,
                          ~Omega[Ar]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearAra

LMER - Omega Inshore

# Inshore dDIC
  hist(inshore.season.data$Aragonite_Sat_W)

  shapiro.test(inshore.season.data$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$Aragonite_Sat_W
## W = 0.98834, p-value = 0.001761
  Omega_seson_in<-lmer(Aragonite_Sat_W~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
      #summary(Omega_seson_in)    
      av.Ome_seson_in<-anova(Omega_seson_in)
      av.Ome_seson_in
      ranova(Omega_seson_in)
      #step(Omega_seson_in)
      
      plot(Omega_seson_in)

      par(mfrow=c(1,2))
      qqnorm(resid(Omega_seson_in))
      acf(resid(Omega_seson_in), main="acf(resid(dTA Season))")

      par(mfrow=c(1,1))
      #summ(dDIC_seson_in, scale = TRUE)
  #plot_summs(Omega_seson_in)
  
  omega_ses_in.emmc<-emmeans(Omega_seson_in, ~ Sub_region*Season)
    omega_ses_in.emmc<-multcomp::cld(omega_ses_in.emmc)
    #omega_ses_in.emmc<-as.data.frame(omega_ses_in.emmc[complete.cases(omega_ses_in.emmc),])
    omega_ses_in.emmc<-omega_ses_in.emmc[order(omega_ses_in.emmc$Season,
                                           omega_ses_in.emmc$Sub_region), ]
  omega_ses_in.emmc

LMER - all pH

# Inshore Omega
  hist(season.data$pH_calculated)

  shapiro.test(season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$pH_calculated
## W = 0.98683, p-value = 2.197e-09
  # pH_seson<-lmer(pH_calculated~ Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  pH_seson<-lmer(pH_calculated~ Zone * Sub_region * Season *
                           (1|SiteID), data=season.data)
  
        #summary(pH_seson)    
        av.pH_seson<-anova(pH_seson)
        av.pH_seson
        ranova(pH_seson)
        #step(pH_seson)
        
        plot(pH_seson)

        par(mfrow=c(1,2))
        qqnorm(resid(pH_seson))
        acf(resid(pH_seson), main="acf(resid(dTA Season))")

        par(mfrow=c(1,1))
  #summ(pH_seson, scale = TRUE)
  #plot_summs(pH_seson)  
  
  pH_ses.emmc<-emmeans(pH_seson, ~Zone*Sub_region*Season)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_seson, ~Zone, by = "Sub_region")
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc
  pH_ses.emmc<-emmeans(pH_seson, ~Zone)
    pH_ses.emmc<-multcomp::cld(pH_ses.emmc)
    pH_ses.emmc<-as.data.frame(pH_ses.emmc[complete.cases(pH_ses.emmc),])
    #pH_ses.emmc<-pH_ses.emmc[order(pH_ses.emmc$Zone, pH_ses.emmc$Season), ]
  pH_ses.emmc

LMER - all dpH - MODEL 15

# Inshore Omega
  hist(season.data$dpH_MY)

  shapiro.test(season.data$dpH_MY) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  season.data$dpH_MY
## W = 0.93245, p-value < 2.2e-16
  # Omega_seson<-lmer(Aragonite_Sat_W~  Zone + Sub_region + Season +
  #                          Zone:Sub_region + Zone:Season + Sub_region:Season+   
  #                          (1|SiteID), data=season.data)
  dpH_seson<-lmer(dpH_MY~  Zone * Sub_region * Season +
                           (1|SiteID), data=season.data)
  
  #summary(dpH_seson)    
  av.dpH_seson<-anova(dpH_seson)
  av.dpH_seson
  ranova(dpH_seson)
  #step(dpH_seson)
  
  plot(dpH_seson)

  par(mfrow=c(1,2))
  qqnorm(resid(dpH_seson))
  acf(resid(dpH_seson), main="acf(resid(dTA Season))")

  par(mfrow=c(1,1))
  #plot_summs(dpH_seson)  
    
dpH_ses.emmc<-emmeans(dpH_seson, ~Zone*Season, by="Sub_region")
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc<-emmeans(dpH_seson, ~Sub_region)
    dpH_ses.emmc<-multcomp::cld(dpH_ses.emmc)
    dpH_ses.emmc
dpH_ses.emmc2<-emmeans(dpH_seson, ~Season*Sub_region, by="Zone")
    dpH_ses.emmc2<-multcomp::cld(dpH_ses.emmc2)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_ses.emmc2<-dpH_ses.emmc2[order(dpH_ses.emmc2$Zone, 
                                     dpH_ses.emmc2$Season, 
                                     dpH_ses.emmc2$Sub_region), ]
  #dpH_ses.emmc2

  dpH_ses.emmc2[,-c(3)] %>% kable("html", digits=2, row.names = F,
                                   caption = "Seasonal d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 16) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 17, 32) %>%
      pack_rows(., "Inshore", 33, 48)
Seasonal d pH
Season Sub_region emmean SE df lower.CL upper.CL .group
Offshore
Winter BB 0.01 0.01 168.33 -0.01 0.03 1
Winter UK 0.01 0.01 195.07 -0.01 0.03 1
Winter MK 0.00 0.01 173.54 -0.01 0.02 1
Winter LK 0.00 0.01 167.46 -0.02 0.01 1
Spring BB 0.00 0.01 140.77 -0.02 0.02 1
Spring UK 0.00 0.01 162.76 -0.02 0.02 1
Spring MK 0.01 0.01 124.80 -0.01 0.03 1
Spring LK -0.01 0.01 121.37 -0.02 0.01 1
Summer BB -0.02 0.01 131.33 -0.04 0.00 1
Summer UK -0.01 0.01 145.36 -0.03 0.01 1
Summer MK -0.01 0.01 131.33 -0.02 0.01 1
Summer LK -0.02 0.01 147.92 -0.03 0.00 1
Fall BB 0.00 0.01 113.15 -0.02 0.02 1
Fall UK 0.00 0.01 138.20 -0.02 0.01 1
Fall MK 0.00 0.01 108.38 -0.01 0.02 1
Fall LK 0.00 0.01 109.45 -0.02 0.01 1
Mid-Channel
Winter BB 0.01 0.01 184.95 -0.01 0.03 12345
Winter UK 0.03 0.01 203.65 0.00 0.05 345
Winter MK 0.01 0.01 173.55 0.00 0.03 2345
Winter LK -0.01 0.01 131.04 -0.03 0.00 123
Spring BB 0.02 0.01 183.76 0.00 0.04 345
Spring UK 0.03 0.01 168.30 0.01 0.06 45
Spring MK 0.04 0.01 118.88 0.02 0.05 5
Spring LK 0.01 0.01 108.38 -0.01 0.02 2345
Summer BB -0.03 0.01 131.33 -0.05 -0.01 12
Summer UK -0.02 0.01 153.58 -0.04 0.00 123
Summer MK -0.02 0.01 131.33 -0.04 -0.01 123
Summer LK -0.03 0.01 145.88 -0.05 -0.02 1
Fall BB -0.02 0.01 121.75 -0.04 0.00 1234
Fall UK -0.01 0.01 141.92 -0.03 0.01 1234
Fall MK -0.01 0.01 113.49 -0.02 0.01 1234
Fall LK -0.02 0.01 99.42 -0.03 0.00 123
Inshore
Winter BB 0.01 0.01 168.33 -0.01 0.04 456
Winter UK 0.03 0.01 225.08 0.02 0.05 67
Winter MK 0.02 0.01 210.79 0.00 0.04 56
Winter LK -0.01 0.01 145.12 -0.03 0.01 345
Spring BB 0.05 0.01 140.79 0.03 0.07 67
Spring UK 0.10 0.01 184.95 0.08 0.11 8
Spring MK 0.07 0.01 108.38 0.05 0.08 78
Spring LK 0.02 0.01 103.71 0.00 0.03 56
Summer BB -0.06 0.01 131.33 -0.08 -0.04 12
Summer UK -0.03 0.01 162.75 -0.05 -0.02 234
Summer MK -0.04 0.01 138.22 -0.06 -0.03 123
Summer LK -0.08 0.01 163.43 -0.10 -0.06 1
Fall BB -0.05 0.01 105.99 -0.07 -0.03 123
Fall UK -0.06 0.01 154.40 -0.08 -0.04 12
Fall MK -0.03 0.01 113.27 -0.04 -0.01 234
Fall LK -0.06 0.01 99.42 -0.07 -0.04 12
  dpH_year.emmc<-emmeans(dpH_seson, ~Sub_region*Zone)
    dpH_year.emmc<-multcomp::cld(dpH_year.emmc)
    #dTA_ses.emmc<-as.data.frame(dTA_ses.emmc[complete.cases(dTA_ses.emmc),])
    dpH_year.emmc<-dpH_year.emmc[order(dpH_year.emmc$Zone, 
                                      dpH_year.emmc$Sub_region), ]
  #dDIC_year.emmc
  
  dpH_year.emmc[,-c(2)] %>% kable("html", digits=2, row.names = F,
                                  caption = "Year d pH") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Offshore", 1, 4) %>% # groups rows with zone label
      pack_rows(., "Mid-Channel", 5, 8) %>%
      pack_rows(., "Inshore", 9, 12)
Year d pH
Sub_region emmean SE df lower.CL upper.CL .group
Offshore
BB 0.00 0.01 20.87 -0.02 0.01 12
UK 0.00 0.01 23.28 -0.01 0.01 2
MK 0.00 0.01 20.40 -0.01 0.01 2
LK -0.01 0.00 20.66 -0.02 0.00 2
Mid-Channel
BB 0.00 0.01 22.64 -0.02 0.01 12
UK 0.01 0.01 23.92 -0.01 0.02 2
MK 0.00 0.01 20.38 -0.01 0.02 2
LK -0.01 0.01 19.00 -0.02 0.00 12
Inshore
BB -0.01 0.01 20.66 -0.02 0.00 12
UK 0.01 0.01 25.52 0.00 0.02 2
MK 0.01 0.01 21.17 -0.01 0.02 2
LK -0.03 0.01 19.68 -0.04 -0.02 1

Figure 4C: Model

dpH_ses_2.emmc<-as.data.frame(dpH_ses.emmc2)
dpH_ye_3.emmc<-as.data.frame(dpH_year.emmc)
dpH_ye_3.emmc$Season<-"Mean"

dpH_all_4<-rbind(dpH_ses_2.emmc, dpH_ye_3.emmc)
dpH_all_4$Zone<-factor(dDIC_all_4$Zone, 
                          levels=c("Inshore" , "Mid channel", "Offshore"))


DeltaYearpH<- ggplot(dpH_all_4, aes(x=Season, y=emmean, fill=Sub_region)) +
        MyTheme +  
        #facet_grid(Zone~., scales = "free_y")+
        facet_grid(~Zone, scales="free" )+
        geom_hline(yintercept = 0, color="gray")+
        theme(axis.title.x = element_blank(),
              legend.position = "bottom",
              axis.text.x = element_text(angle = 0))+

    scale_y_continuous(#limits = c(-350,340),
                     expand = c(0.01, 0.01),
                     breaks = seq(-6, 6, 0.05),
                     name=(expression (paste(Delta ,
                          ~pH[]))))+
    geom_bar(position = "dodge", color="black", 
           stat = "summary",
           fun = "mean")+
  geom_errorbar(aes(ymin=emmean-SE, ymax=emmean+SE), width=0.2,
                 position=position_dodge(.9)) 

DeltaYearpH

LMER - pH Inshore

# Inshore pH
  hist(inshore.season.data$pH_calculated)

  shapiro.test(inshore.season.data$pH_calculated) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  inshore.season.data$pH_calculated
## W = 0.99301, p-value = 0.04501
  pH_seson_in<-lmer(pH_calculated~  Sub_region * Season +
                           (1|SiteID), data=inshore.season.data)
  
    #summary(pH_seson_in)    
    av.pH_seson_in<-anova(pH_seson_in)
    av.pH_seson_in
    ranova(pH_seson_in)
    #step(pH_seson_in)
    
    plot(pH_seson_in)

    par(mfrow=c(1,2))
    qqnorm(resid(pH_seson_in))
    acf(resid(pH_seson_in), main="acf(resid(dTA Season))")

    par(mfrow=c(1,1))
    #summ(pH_seson_in, scale = TRUE)
    #plot_summs(pH_seson_in)
  
  pH_ses_in.emmc<-emmeans(pH_seson_in, ~ Sub_region*Season)
    pH_ses_in.emmc<-multcomp::cld(pH_ses_in.emmc)
    #pH_ses_in.emmc<-as.data.frame(pH_ses_in.emmc[complete.cases(pH_ses_in.emmc),])
    pH_ses_in.emmc<-pH_ses_in.emmc[order(pH_ses_in.emmc$Season,
                                           pH_ses_in.emmc$Sub_region), ]
  pH_ses_in.emmc

Summary all data

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_seson <- data.frame(av.dTA_seson)
    av.dDIC_seson <- data.frame(av.dDIC_seson) 
    av.dPCO2_seson <- data.frame(av.dPCO2_seson)
    av.dOme_seson <- data.frame(av.dOme_seson) 
    av.dpH_seson <- data.frame(av.dpH_seson) 
    
    # Putting all into one dataframe/table
    anova_results_all <- data.frame(cbind
                    (c("Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season",
                       
                       "Zone", "Sub_region", "Season", "Zone:Sub_region", "Zone:Season",
                       "Sub_region:Season", "Zone:Sub_region:Season"), 
                                      rbind(av.dTA_seson, av.dDIC_seson, av.dPCO2_seson,
                                            av.dOme_seson, av.dpH_seson ))) 
    colnames(anova_results_all) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_all) <- NULL
    
    # create HTML table using kableExtra
    anova_results_all %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA", 1, 7) %>% # groups rows with label
      pack_rows(., "d DIC", 8, 14)  %>% # groups rows with label
      pack_rows(., "d pCO2", 15, 21) %>% # groups rows with label
      pack_rows(., "d Omega", 22, 28)  %>% # groups rows with label
      pack_rows(., "d pH", 29, 35)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA
Zone 119622.09 59811.05 2 24.12 27.05 0.00
Sub_region 225708.04 75236.01 3 23.87 34.02 0.00
Season 796380.13 265460.04 3 1213.79 120.04 0.00
Zone:Sub_region 172457.19 28742.87 6 23.87 13.00 0.00
Zone:Season 519488.58 86581.43 6 1213.80 39.15 0.00
Sub_region:Season 125423.53 13935.95 9 1213.74 6.30 0.00
Zone:Sub_region:Season 65675.63 3648.65 18 1213.75 1.65 0.04
d DIC
Zone 40877.81 20438.90 2 23.32 8.82 0.00
Sub_region 77412.09 25804.03 3 23.18 11.14 0.00
Season 1334571.06 444857.02 3 1207.98 192.02 0.00
Zone:Sub_region 61014.64 10169.11 6 23.18 4.39 0.00
Zone:Season 995266.35 165877.72 6 1207.99 71.60 0.00
Sub_region:Season 157113.65 17457.07 9 1207.95 7.54 0.00
Zone:Sub_region:Season 94802.45 5266.80 18 1207.96 2.27 0.00
d pCO2
Zone 12741.48 6370.74 2 21.66 2.64 0.09
Sub_region 58508.24 19502.75 3 21.54 8.09 0.00
Season 911341.19 303780.40 3 1204.54 125.94 0.00
Zone:Sub_region 13990.74 2331.79 6 21.55 0.97 0.47
Zone:Season 607986.17 101331.03 6 1204.55 42.01 0.00
Sub_region:Season 68277.65 7586.41 9 1204.50 3.15 0.00
Zone:Sub_region:Season 59111.43 3283.97 18 1204.52 1.36 0.14
d Omega
Zone 2.11 1.05 2 21.16 13.57 0.00
Sub_region 6.49 2.16 3 20.98 27.90 0.00
Season 32.54 10.85 3 1204.39 139.81 0.00
Zone:Sub_region 2.63 0.44 6 20.99 5.64 0.00
Zone:Season 20.31 3.39 6 1204.40 43.63 0.00
Sub_region:Season 2.33 0.26 9 1204.34 3.33 0.00
Zone:Sub_region:Season 1.73 0.10 18 1204.36 1.24 0.22
d pH
Zone 0.00 0.00 2 22.06 1.17 0.33
Sub_region 0.07 0.02 3 21.93 13.57 0.00
Season 0.66 0.22 3 1204.97 133.06 0.00
Zone:Sub_region 0.02 0.00 6 21.93 2.45 0.06
Zone:Season 0.39 0.06 6 1204.98 38.92 0.00
Sub_region:Season 0.04 0.00 9 1204.93 2.62 0.01
Zone:Sub_region:Season 0.03 0.00 18 1204.94 1.09 0.35
#export_summs(dTA_seson, dDIC_seson, dpCO2_seson,  scale = TRUE)
      
      Seasonal_models<-list("d TA" = dTA_seson, 
                         "d DIC" = dDIC_seson, 
                         "d pCO2" = dpCO2_seson, 
                         "Omega" = Omega_seson,
                         "pH" = pH_seson)
      
      modelsummary(Seasonal_models, stars = TRUE, 
                   #statistic = c('std.error', 'p.value', 'conf.int'),
                   title = 'Seasonal and spatial models'#,
                   #coef_map=factor_order
                   )
Seasonal and spatial models
d TA d DIC d pCO2 Omega pH
(Intercept) 1.046 −1.155 −7.598 3.699*** 8.074***
(11.864) (12.721) (13.151) (0.072) (0.012)
ZoneMid channel 6.972 11.804 1.345 −0.061 −0.002
(17.018) (18.225) (18.834) (0.103) (0.017)
ZoneInshore 39.553* 48.047** 4.105 −0.083 0.006
(16.778) (17.991) (18.599) (0.102) (0.017)
Sub_regionUK 2.845 1.059 −1.212 −0.009 −0.003
(15.625) (16.728) (17.286) (0.095) (0.015)
Sub_regionMK 3.551 9.089 5.808 −0.057 −0.004
(15.373) (16.478) (17.034) (0.093) (0.015)
Sub_regionLK 0.902 8.485 9.571 −0.109 −0.010
(14.532) (15.462) (16.110) (0.088) (0.014)
SeasonSpring −4.947 0.623 9.930 0.056 −0.036*
(15.702) (16.073) (16.401) (0.093) (0.015)
SeasonSummer −5.756 5.682 27.158+ 0.127 −0.081***
(15.514) (15.879) (16.203) (0.094) (0.015)
SeasonFall −1.087 4.823 11.334 0.023 −0.042**
(15.186) (15.543) (15.860) (0.092) (0.015)
ZoneMid channelSub_regionUK −0.207 −9.979 −15.897 0.121 0.020
(23.476) (25.103) (25.932) (0.142) (0.023)
ZoneInshoreSub_regionUK 5.292 −4.871 −18.249 0.106 0.020
(22.302) (23.856) (24.647) (0.135) (0.022)
ZoneMid channelSub_regionMK 13.666 4.728 −6.319 0.118 0.014
(21.926) (23.485) (24.272) (0.133) (0.022)
ZoneInshoreSub_regionMK 12.846 −0.469 −11.129 0.157 0.014
(22.017) (23.574) (24.361) (0.133) (0.022)
ZoneMid channelSub_regionLK 4.618 12.666 18.821 −0.037 −0.007
(20.998) (22.442) (23.291) (0.127) (0.021)
ZoneInshoreSub_regionLK −34.186 −27.490 12.977 −0.069 −0.011
(20.931) (22.379) (23.227) (0.127) (0.021)
ZoneMid channelSeasonSpring −11.689 −33.140 −31.214 0.215 0.031
(22.871) (23.413) (23.890) (0.135) (0.022)
ZoneInshoreSeasonSpring −98.226*** −138.400*** −67.837** 0.398** 0.048*
(22.206) (22.731) (23.194) (0.131) (0.021)
ZoneMid channelSeasonSummer −13.769 −8.830 16.437 −0.058 −0.012
(22.124) (22.645) (23.106) (0.134) (0.022)
ZoneInshoreSeasonSummer −72.467*** −53.973* 57.295* −0.223+ −0.052*
(21.940) (22.457) (22.915) (0.133) (0.022)
ZoneMid channelSeasonFall −2.906 5.739 17.134 −0.089 −0.013
(21.775) (22.288) (22.742) (0.132) (0.022)
ZoneInshoreSeasonFall −16.132 17.489 64.149** −0.354** −0.049*
(21.374) (21.877) (22.323) (0.129) (0.021)
Sub_regionUKSeasonSpring −0.926 −2.034 −1.722 0.044 0.004
(20.692) (21.187) (21.620) (0.123) (0.020)
Sub_regionMKSeasonSpring −7.110 −22.160 −21.626 0.161 0.019
(20.159) (20.635) (21.056) (0.119) (0.020)
Sub_regionLKSeasonSpring −8.486 −14.015 −4.737 0.079 0.004
(19.088) (19.444) (19.940) (0.114) (0.019)
Sub_regionUKSeasonSummer −3.509 −8.777 −7.786 0.082 0.009
(20.392) (20.873) (21.298) (0.123) (0.020)
Sub_regionMKSeasonSummer −20.367 −31.180 −21.263 0.102 0.013
(20.072) (20.545) (20.963) (0.121) (0.020)
Sub_regionLKSeasonSummer −6.527 −12.633 −7.810 0.073 0.007
(19.002) (19.474) (19.970) (0.116) (0.019)
Sub_regionUKSeasonFall −4.270 −2.330 −0.322 −0.006 0.000
(20.077) (20.551) (20.970) (0.121) (0.020)
Sub_regionMKSeasonFall −4.739 −12.228 −11.203 0.078 0.011
(19.600) (20.062) (20.471) (0.118) (0.019)
Sub_regionLKSeasonFall −4.216 −10.678 −9.389 0.104 0.009
(18.570) (18.908) (19.395) (0.112) (0.018)
ZoneMid channelSub_regionUKSeasonSpring 3.883 3.766 9.527 0.014 −0.017
(31.342) (32.088) (32.744) (0.186) (0.030)
ZoneInshoreSub_regionUKSeasonSpring −1.706 −28.388 −22.485 0.259 0.030
(29.533) (30.236) (30.853) (0.175) (0.029)
ZoneMid channelSub_regionMKSeasonSpring −38.796 −35.493 1.646 −0.065 −0.019
(28.992) (29.677) (30.282) (0.172) (0.028)
ZoneInshoreSub_regionMKSeasonSpring −27.635 −25.974 4.715 −0.060 −0.008
(28.609) (29.285) (29.882) (0.170) (0.028)
ZoneMid channelSub_regionLKSeasonSpring −37.531 −38.762 −9.249 −0.021 −0.005
(27.924) (28.519) (29.169) (0.166) (0.027)
ZoneInshoreSub_regionLKSeasonSpring −20.162 −7.749 6.528 −0.173 −0.017
(27.444) (28.027) (28.667) (0.163) (0.027)
ZoneMid channelSub_regionUKSeasonSummer 5.033 10.845 13.219 −0.059 −0.015
(30.577) (31.297) (31.935) (0.185) (0.030)
ZoneInshoreSub_regionUKSeasonSummer −0.414 −8.093 −14.084 0.145 0.008
(29.102) (29.787) (30.395) (0.176) (0.029)
ZoneMid channelSub_regionMKSeasonSummer −46.965+ −41.015 −0.563 −0.097 −0.016
(28.528) (29.200) (29.795) (0.172) (0.028)
ZoneInshoreSub_regionMKSeasonSummer −80.525** −74.575* −25.773 −0.149 −0.004
(28.642) (29.316) (29.914) (0.173) (0.028)
ZoneMid channelSub_regionLKSeasonSummer −54.821* −66.591* −30.145 0.032 0.006
(27.520) (28.282) (28.928) (0.167) (0.027)
ZoneInshoreSub_regionLKSeasonSummer −79.637** −62.700* −15.649 −0.147 −0.006
(27.564) (28.343) (28.989) (0.168) (0.027)
ZoneMid channelSub_regionUKSeasonFall −1.908 6.079 13.033 −0.107 −0.015
(30.174) (30.885) (31.514) (0.182) (0.030)
ZoneInshoreSub_regionUKSeasonFall 16.349 30.699 42.284 −0.133 −0.028
(28.576) (29.251) (29.847) (0.173) (0.028)
ZoneMid channelSub_regionMKSeasonFall −10.458 −1.525 3.017 −0.118 −0.011
(27.985) (28.644) (29.228) (0.169) (0.028)
ZoneInshoreSub_regionMKSeasonFall −20.494 −17.950 −15.134 −0.051 0.002
(27.893) (28.551) (29.133) (0.169) (0.028)
ZoneMid channelSub_regionLKSeasonFall −16.475 −26.842 −23.332 0.062 0.012
(26.899) (27.465) (28.094) (0.163) (0.027)
ZoneInshoreSub_regionLKSeasonFall −45.957+ −45.562+ −21.920 −0.065 0.004
(26.675) (27.236) (27.861) (0.161) (0.026)
SD (Intercept SiteID) 4.615 7.143 7.876 0.029 0.005
SD (Observations) 47.026 48.132 49.113 0.284 0.046
Num.Obs. 1279 1274 1272 1286 1286
R2 Marg. 0.460 0.512 0.363 0.428 0.477
R2 Cond. 0.465 0.523 0.379 0.433 0.482
AIC 13236.2 13246.6 13276.3 660.9 −3824.1
BIC 13493.9 13504.1 13533.7 918.9 −3566.1
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 46.03 47.03 47.97 0.28 0.05
+ p
      #modelsummary(Omega_models, estimate = "p.value")

Summary all inshore

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.dTA_seson_in <- data.frame(av.dTA_seson_in)
    av.dDIC_seson_in <- data.frame(av.dDIC_seson_in) 
    av.dPCO2_seson_in <- data.frame(av.dPCO2_seson_in)
    av.Ome_seson_in <- data.frame(av.Ome_seson_in) 
    av.pH_seson_in <- data.frame(av.pH_seson_in) 
    
    # Putting all into one dataframe/table
    anova_results_In <- data.frame(cbind
                    (c("Sub_region", "Season", "Sub_region:Season", 
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season",
                       
                       "Sub_region", "Season", "Sub_region:Season"), 
                                      rbind(av.dTA_seson_in, av.dDIC_seson_in,
                                            av.dPCO2_seson_in,
                                            av.Ome_seson_in, av.pH_seson_in))) 
    colnames(anova_results_In) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_results_In) <- NULL
    
    # create HTML table using kableExtra
    anova_results_In %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "d TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "d DIC inshore", 4, 6)  %>% # groups rows with label
      pack_rows(., "d pCO2 inshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega inshore", 10, 12)  %>% # groups rows with label
      pack_rows(., "pH inshore", 13, 15)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
d TA inshore
Sub_region 401280.22 133760.07 3 8.33 27.61 0.00
Season 1150047.96 383349.32 3 400.68 79.12 0.00
Sub_region:Season 120564.92 13396.10 9 400.67 2.76 0.00
d DIC inshore
Sub_region 111762.35 37254.12 3 7.77 7.26 0.01
Season 2083817.92 694605.97 3 398.06 135.42 0.00
Sub_region:Season 156504.72 17389.41 9 398.06 3.39 0.00
d pCO2 inshore
Sub_region 42827.75 14275.92 3 7.14 2.77 0.12
Season 1317546.80 439182.27 3 397.46 85.30 0.00
Sub_region:Season 97882.98 10875.89 9 397.46 2.11 0.03
Omega inshore
Sub_region 6.33 2.11 3 6.98 15.02 0.00
Season 45.98 15.33 3 403.42 109.14 0.00
Sub_region:Season 3.57 0.40 9 403.42 2.83 0.00
pH inshore
Sub_region 0.07 0.02 3 7.35 6.00 0.02
Season 1.53 0.51 3 403.72 130.42 0.00
Sub_region:Season 0.07 0.01 9 403.72 1.92 0.05
#export_summs(dTA_seson, dDIC_seson, dpCO2_seson,  scale = TRUE)
    Seasonal_models_in<-list("d TA" = dTA_seson_in, 
                       "d DIC" = dDIC_seson_in, 
                       "d pCO2" = dpCO2_seson_in, 
                       "Omega" = Omega_seson_in,
                       "pH" = pH_seson_in)
    
    modelsummary(Seasonal_models_in, stars = TRUE, 
                 #statistic = c('std.error', 'p.value', 'conf.int'),
                 title = 'Seasonal and spatial models for inshore reefs'#,
                 #coef_map=factor_order
                 )
Seasonal and spatial models for inshore reefs
d TA d DIC d pCO2 Omega pH
(Intercept) 40.629* 46.881* −3.561 3.617*** 8.080***
(17.194) (19.028) (19.810) (0.098) (0.016)
Sub_regionUK 8.138 −3.796 −19.308 0.096 0.017
(23.097) (25.432) (26.413) (0.131) (0.022)
Sub_regionMK 16.388 8.631 −5.233 0.100 0.009
(22.868) (25.208) (26.196) (0.130) (0.022)
Sub_regionLK −33.089 −19.024 22.567 −0.179 −0.021
(21.813) (24.202) (25.227) (0.124) (0.021)
SeasonSpring −103.123*** −137.797*** −58.022* 0.454*** 0.012
(23.240) (23.916) (23.963) (0.122) (0.020)
SeasonSummer −78.253*** −48.281* 84.522*** −0.097 −0.132***
(22.963) (23.628) (23.674) (0.124) (0.021)
SeasonFall −17.227 22.315 75.501** −0.331** −0.091***
(22.263) (22.907) (22.951) (0.120) (0.020)
Sub_regionUKSeasonSpring −2.714 −30.408 −24.177 0.303+ 0.034
(31.189) (32.097) (32.161) (0.164) (0.027)
Sub_regionMKSeasonSpring −34.803 −48.114 −16.803 0.101 0.011
(30.047) (30.919) (30.979) (0.159) (0.027)
Sub_regionLKSeasonSpring −28.867 −21.726 1.900 −0.094 −0.013
(29.183) (30.034) (30.094) (0.155) (0.026)
Sub_regionUKSeasonSummer −3.909 −16.884 −21.992 0.228 0.017
(30.731) (31.621) (31.682) (0.165) (0.028)
Sub_regionMKSeasonSummer −100.909*** −105.767*** −47.138 −0.046 0.009
(30.242) (31.118) (31.179) (0.163) (0.027)
Sub_regionLKSeasonSummer −86.260** −75.315* −23.448 −0.074 0.001
(29.553) (30.642) (30.702) (0.160) (0.027)
Sub_regionUKSeasonFall 12.055 28.360 41.860 −0.138 −0.029
(30.098) (30.972) (31.032) (0.162) (0.027)
Sub_regionMKSeasonFall −25.238 −30.180 −26.375 0.027 0.013
(29.374) (30.227) (30.286) (0.158) (0.026)
Sub_regionLKSeasonFall −50.391+ −56.213+ −31.278 0.039 0.013
(28.344) (29.167) (29.225) (0.153) (0.025)
SD (Intercept SiteID) 4.602 10.976 13.375 0.051 0.009
SD (Observations) 69.606 71.618 71.755 0.375 0.063
Num.Obs. 422 420 420 426 426
R2 Marg. 0.473 0.539 0.402 0.503 0.503
R2 Cond. 0.476 0.550 0.422 0.511 0.514
AIC 4686.4 4690.1 4693.1 450.5 −1016.9
BIC 4759.2 4762.8 4765.8 523.5 −943.9
ICC 0.0 0.0 0.0 0.0 0.0
RMSE 68.19 69.95 70.03 0.37 0.06
+ p
    #modelsummary(Omega_models, estimate = "p.value")

Figure 4: Models

Figure_4<-ggarrange(DeltaYearTA+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  DeltaYearDIC+ theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearpH + theme(legend.position = "none",
                                 axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 strip.text.x = element_blank()),
                  DeltaYearAra+ theme(legend.position = "bottom",
                                 strip.text.x = element_blank(),
                                 panel.spacing = unit(0.8, "lines")),
          labels = c("A", "B", "C", "D"),
          ncol = 1, nrow = 4, heights = c(1, 0.9, 0.9, 1.2))
Figure_4

#ggsave(file="FLK_results/Figures/Fig_4/Figure_4.svg", plot=Figure_4, dpi = 300, width=8, height=7)

6 LMER long trend MODELS

  • The F statistic in a regression model is used to test whether there is a linear model of the data - overall , or equivalently that your model is no better than a model with just the intercept.

  • The t statistic for a coefficient in a linear model tests the H0 that the true coefficient is 0.

*The t-statistic is telling you about each coefficient individually. You can have a model with a low overall linear fit, but one individual coefficient may be relatively contributing a lot to explanation the variation in the DV that is explained on the assumption that there is a linear model.

Data and plots prep

Trends.data<-FLK.data_filtered[FLK.data_filtered$Year>2014, ]
#summary(Trends.data)

Reef.Trends.data<-WS.reef[WS.reef$Year>2014, ]
Reef.Trends.data<-Reef.Trends.data[Reef.Trends.data$Extreme=="Normal", ]
#summary(Reef.Trends.data$Extreme)

Trends.ocean<-Trends.data[Trends.data$Zone=="Oceanic", ]

Trends.offshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Offshore", ]
Trends.midchanel<-Reef.Trends.data[Reef.Trends.data$Zone=="Mid channel", ]
Trends.inshore<-Reef.Trends.data[Reef.Trends.data$Zone=="Inshore", ]

Long_plot<- ggplot(Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))

Long_plot2<- ggplot() +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank(),
                axis.text.x = element_text(angle = 0, vjust = 0.5))+
        scale_x_date(date_breaks = "2 years",
                     date_labels = "%Y",
                     expand = c(0.02, 0.02))
xs <- as.Date(as.character("2018-11-20"))

factor_order <- c('Year'    = 'Year',
                  '(Intercept)' = 'Intercept',
                  'Sub_regionUK'    = 'Upper Keys',
                  'Sub_regionMK'    = 'Middle Keys',
                  'Sub_regionLK'    = 'Lower Keys')

Omega-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$Aragonite_Sat_W
## W = 0.97568, p-value = 4.918e-14

## Model with all data
Omega_all_o<-lmer(Aragonite_Sat_W~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
  step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -319.09  704.18                         
## (1 | SiteID)          1   32 -319.34  702.67   0.49  1     0.4849    
## (1 | Month)           0   31 -506.30 1074.59 373.92  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Year:Zone:Sub_region          1 0.1753 0.02192     8 1265.1  0.2644  0.97717
## Year:Sub_region               2 0.1009 0.03364     3 1273.3  0.4077  0.74747
## Year:Zone                     0 0.6658 0.22195     3 1276.1  2.6936  0.04482
## Zone:Sub_region               0 5.4769 0.68461     8 1276.1  8.3088 4.94e-11
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
Omega_all_1<-lmer(Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

Omega_all_3<-lmer(Aragonite_Sat_W ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(Omega_all_1, Omega_all_3)
    summary(Omega_all_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 575.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6656 -0.5694  0.0463  0.5720  5.0564 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.03497  0.187   
##  Residual             0.08240  0.287   
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   1.490e+01  1.560e+01  1.284e+03   0.955 0.339581
## Year                         -5.593e-03  7.731e-03  1.284e+03  -0.723 0.469543
## ZoneMid channel               1.716e+01  2.128e+01  1.276e+03   0.806 0.420124
## ZoneOffshore                  4.646e+01  2.027e+01  1.276e+03   2.292 0.022080
## ZoneOceanic                   6.184e+01  2.675e+01  1.276e+03   2.312 0.020945
## Sub_regionUK                  2.151e-01  4.496e-02  1.276e+03   4.784 1.92e-06
## Sub_regionMK                  9.895e-02  4.403e-02  1.276e+03   2.247 0.024790
## Sub_regionLK                 -2.573e-01  4.378e-02  1.276e+03  -5.876 5.36e-09
## Year:ZoneMid channel         -8.460e-03  1.055e-02  1.276e+03  -0.802 0.422573
## Year:ZoneOffshore            -2.295e-02  1.005e-02  1.276e+03  -2.285 0.022481
## Year:ZoneOceanic             -3.044e-02  1.325e-02  1.276e+03  -2.297 0.021795
## ZoneMid channel:Sub_regionUK -1.016e-01  6.705e-02  1.276e+03  -1.515 0.129982
## ZoneOffshore:Sub_regionUK    -1.850e-01  6.305e-02  1.276e+03  -2.934 0.003403
## ZoneOceanic:Sub_regionUK     -4.041e-01  7.599e-02  1.276e+03  -5.318 1.24e-07
## ZoneMid channel:Sub_regionMK -3.360e-02  6.225e-02  1.276e+03  -0.540 0.589463
## ZoneOffshore:Sub_regionMK    -8.265e-02  6.206e-02  1.276e+03  -1.332 0.183203
## ZoneOceanic:Sub_regionMK     -3.155e-01  6.396e-02  1.276e+03  -4.933 9.18e-07
## ZoneMid channel:Sub_regionLK  1.714e-01  6.195e-02  1.276e+03   2.767 0.005738
## ZoneOffshore:Sub_regionLK     2.059e-01  6.029e-02  1.276e+03   3.415 0.000658
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                 *  
## ZoneOceanic                  *  
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel            
## Year:ZoneOffshore            *  
## Year:ZoneOceanic             *  
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    ** 
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK ** 
## ZoneOffshore:Sub_regionLK    ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(Omega_all_1)
    ranova(Omega_all_1)
# Obtain slopes
    
    ranef(Omega_all_1)
## $Month
##      (Intercept)
## Apr  0.268648476
## May  0.283884515
## Jun  0.077513882
## Jul  0.008998083
## Aug  0.181905585
## Sep -0.106124564
## Oct -0.016061919
## Nov -0.272080336
## Dec -0.180108577
## Jan -0.231137664
## Feb -0.083923702
## Mar  0.068486220
## 
## with conditional variances for "Month"
    fixef(Omega_all_1)
##                  (Intercept)                         Year 
##                 14.904215429                 -0.005592579 
##              ZoneMid channel                 ZoneOffshore 
##                 17.161465548                 46.457730421 
##                  ZoneOceanic                 Sub_regionUK 
##                 61.837031801                  0.215079092 
##                 Sub_regionMK                 Sub_regionLK 
##                  0.098946926                 -0.257272634 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                 -0.008459574                 -0.022952973 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                 -0.030443872                 -0.101596941 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                 -0.185014457                 -0.404066643 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                 -0.033599868                 -0.082648315 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                 -0.315507684                  0.171425236 
##    ZoneOffshore:Sub_regionLK 
##                  0.205899946
    coef(Omega_all_1)$Month
    coef(Omega_all_1)$Zone
## NULL
  m.lst <- lstrends(Omega_all_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df lower.CL upper.CL
##  Inshore       -0.00559 0.00774 1284  -0.0208  0.00958
##  Mid channel   -0.01405 0.00798 1284  -0.0297  0.00160
##  Offshore      -0.02855 0.00729 1284  -0.0428 -0.01424
##  Oceanic       -0.03604 0.01129 1280  -0.0582 -0.01388
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate     SE   df t.ratio p.value
##  Inshore - Mid channel   0.00846 0.0105 1276   0.802  0.8534
##  Inshore - Offshore      0.02295 0.0100 1276   2.285  0.1021
##  Inshore - Oceanic       0.03044 0.0133 1276   2.297  0.0993
##  Mid channel - Offshore  0.01449 0.0102 1276   1.416  0.4895
##  Mid channel - Oceanic   0.02198 0.0134 1276   1.641  0.3560
##  Offshore - Oceanic      0.00749 0.0130 1276   0.576  0.9393
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore Omega
  hist(Trends.inshore$Aragonite_Sat_W)

  shapiro.test(Trends.inshore$Aragonite_Sat_W) # Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$Aragonite_Sat_W
## W = 0.98599, p-value = 0.001134
  Omega_in_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month)+
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  Omega_in_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
                                    #(1|Zone)+             
                                    (1|SiteID), data=Trends.inshore)
  
  #summary(Omega_in_0)
  #summary(Omega_in_1)    
  #anova(Omega_in_0, Omega_in_1)
  #step(Omega_in_1)
  
  anova(Omega_in_0)
  ranova(Omega_in_0)
  step(Omega_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -158.47 338.94                         
## (1 | SiteID)          1   10 -159.74 339.47   2.53  1     0.1117    
## (1 | Month)           0    9 -292.29 602.58 265.11  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  0.0569  0.0190     3 354.17  0.1691 0.9172    
## Year                     2  0.1096  0.1096     1 364.53  0.9841 0.3218    
## Sub_region               0 10.9897  3.6632     3 358.15 32.8925 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Sub_region + (1 | Month)
  Omega_in<-lmer(Aragonite_Sat_W ~ Sub_region + (1 | Month),
                 data=Trends.inshore)
  anova(Omega_in)
  summary(Omega_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 296.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8609 -0.5681  0.0603  0.5554  4.0778 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.1496   0.3868  
##  Residual             0.1114   0.3337  
## Number of obs: 373, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)    3.63208    0.11850  13.30859  30.651 9.81e-14 ***
## Sub_regionUK   0.20027    0.05227 358.12645   3.832  0.00015 ***
## Sub_regionMK   0.09924    0.05124 358.13089   1.937  0.05359 .  
## Sub_regionLK  -0.24632    0.05098 358.14454  -4.831 2.02e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.247              
## Sub_reginMK -0.253  0.571       
## Sub_reginLK -0.255  0.572  0.587
  plot(Omega_in)

  qqnorm(resid(Omega_in))

  acf(resid(Omega_in), main="acf(resid(Omega Inshore))")

  Arg_in.emmc<-emmeans(Omega_in, ~Sub_region)
    Arg_in.emmc<-multcomp::cld(Arg_in.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_in.emmc<-Arg_in.emmc[order(Arg_in.emmc$Sub_region),]
    Arg_in.emmc
  #write.csv(Arg_in.emmc, "FLK_results/Model_9_LTpH_POST.csv")
    round(Arg_in.emmc$emmean, digits = 2)
## [1] 3.63 3.83 3.73 3.39
  #anova(Omega_in)
  #ranova(Omega_in)
# Create a new data frame for independent variables  
  In_Newdata<-expand.grid(Zone=unique(Trends.inshore$Zone),
                          Sub_region=unique(Trends.inshore$Sub_region),
                          Year=seq((min(Trends.inshore$Year)-0), (max(Trends.inshore$Year)+1)))
  In_Omega_Pred <- predict(Omega_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_Omega_Pred <-cbind(In_Newdata, In_Omega_Pred)
  In_Omega_Pred$Date<-as.Date(as.character(In_Omega_Pred$Year), format = "%Y")
  
  
# Plot raw data point and fitted model 
  
  In_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(0,6),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_Omega_Pred, aes(y = In_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=2, size=1) 
  In_Omega_Modeled

Mid channel

hist(Trends.midchanel$Aragonite_Sat_W)

shapiro.test(Trends.midchanel$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$Aragonite_Sat_W
## W = 0.98399, p-value = 0.0006581
Omega_mc_0<-lmer(Aragonite_Sat_W~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)

# Omega_mc_1<-lmer(Aragonite_Sat_W~Year * Sub_region * Season +
#                                     #(1|Zone)+             
#                                     (1|SiteID), data=Trends.midchanel)

#summary(Omega_mc_0)    
#summary(Omega_mc_1)  

anova(Omega_mc_0)
#anova(Omega_mc_1)
#anova(Omega_mc_0, Omega_mc_1)
ranova(Omega_mc_0)
step(Omega_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar   logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11  -33.105  88.211                          
## (1 | SiteID)          1   10  -33.637  87.274   1.063  1     0.3025    
## (1 | Month)           0    9 -102.380 222.760 137.486  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.12890 0.04297     3 329.13  0.7493   0.52339    
## Year                     0 0.24196 0.24196     1 342.10  4.2296   0.04048 *  
## Sub_region               0 1.99759 0.66586     3 332.22 11.6397 2.849e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
Omega_mc<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month),
               data = Trends.midchanel)
  summary(Omega_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 50.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2542 -0.5546  0.0284  0.5818  3.4212 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.04181  0.2045  
##  Residual             0.05721  0.2392  
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)   
## (Intercept)   34.412104  14.931233 342.106233   2.305  0.02178 * 
## Year          -0.015216   0.007399 342.099332  -2.057  0.04048 * 
## Sub_regionUK   0.115884   0.041502 332.216472   2.792  0.00554 **
## Sub_regionMK   0.065034   0.036727 332.152378   1.771  0.07752 . 
## Sub_regionLK  -0.085215   0.036655 332.240537  -2.325  0.02069 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.016  0.532  0.601
  anova(Omega_mc) 
  plot(Omega_mc)

  qqnorm(resid(Omega_mc))

  acf(resid(Omega_mc), main="acf(resid(Omega mid Channel))")  

  Arg_md.emmc<-emmeans(Omega_mc, ~Sub_region+Year)
    Arg_md.emmc<-multcomp::cld(Arg_md.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_md.emmc<-Arg_md.emmc[order(Arg_md.emmc$Sub_region),]
    Arg_md.emmc
  #write.csv(Arg_md.emmc, "FLK_results/Model_10_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Mc_Newdata<-expand.grid(Zone=unique(Trends.midchanel$Zone),
                                Sub_region=unique(Trends.midchanel$Sub_region),
                          Year=seq((min(Trends.midchanel$Year)-0), (max(Trends.midchanel$Year)+1)))
  Mc_Omega_Pred <- predict(Omega_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_Omega_Pred <-cbind(Mc_Newdata, Mc_Omega_Pred)
  Mc_Omega_Pred$Date<-as.Date(as.character(Mc_Omega_Pred$Year), format = "%Y")
  
  
# Model summary for labels
  slope<-round(
      summary(Omega_mc)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.midchanel$Aragonite_Sat_W, na.rm =T)+ 0.3

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  Mc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                       name=(expression(~Omega[Ar])),
                       limits = c(2.3, 5.2),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_jitter(data=Trends.midchanel, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_Omega_Pred, aes(y = Mc_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      # geom_text(data = slope, aes(x = xs, y = ys,
      #                       label = (paste("~Omega[Ar]", "=", 
      #                                     slope, "Year ^-1"))), size=10)
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_Omega_Modeled

Offshore

hist(Trends.offshore$Aragonite_Sat_W)

shapiro.test(Trends.offshore$Aragonite_Sat_W)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$Aragonite_Sat_W
## W = 0.99121, p-value = 0.0128
Omega_of_0<-lmer(Aragonite_Sat_W~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
#summary(Omega_of_0)    
anova(Omega_of_0)
ranova(Omega_of_0)
step(Omega_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC     LRT Df Pr(>Chisq)    
## <none>                    11 153.652 -285.30                          
## (1 | SiteID)          1   10 153.486 -286.97   0.332  1     0.5644    
## (1 | Month)           0    9  86.497 -154.99 133.977  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.04838 0.01613     3 404.94  0.6907    0.5581    
## Year                     0 0.98863 0.98863     1 418.90 42.4403 2.093e-10 ***
## Sub_region               0 0.55609 0.18536     3 408.08  7.9574 3.619e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
Omega_of<-lmer(Aragonite_Sat_W ~ Year + Sub_region + (1 | Month), 
               data =Trends.offshore)
  summary(Omega_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -327.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8494 -0.6878  0.0746  0.6305  3.5033 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01341  0.1158  
##  Residual             0.02329  0.1526  
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   59.846389   8.611290 418.898403   6.950 1.41e-11 ***
## Year          -0.027797   0.004267 418.895440  -6.515 2.09e-10 ***
## Sub_regionUK   0.019509   0.023509 407.966516   0.830  0.40710    
## Sub_regionMK   0.017049   0.023277 407.960709   0.732  0.46432    
## Sub_regionLK  -0.062086   0.022129 408.171391  -2.806  0.00526 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.013  0.012  0.623  0.630
  anova(Omega_of) 
  plot(Omega_of)

  qqnorm(resid(Omega_of))

  acf(resid(Omega_of), main="acf(resid(Omega offshore))")  

  Arg_of.emmc<-emmeans(Omega_of, ~Sub_region+Year)
    Arg_of.emmc<-multcomp::cld(Arg_of.emmc)
    #Arg_in.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    Arg_of.emmc<-Arg_of.emmc[order(Arg_of.emmc$Sub_region),]
    Arg_of.emmc
#write.csv(Arg_of.emmc, "FLK_results/Model_11_LTpH_POST.csv")
# Create a new data frame for independent variables  
  Of_Newdata<-expand.grid(one=unique(Trends.offshore$Zone),
                                Sub_region=unique(Trends.offshore$Sub_region),
                          Year=seq((min(Trends.offshore$Year)-0), (max(Trends.offshore$Year)+1)))
  Of_Omega_Pred <- predict(Omega_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_Omega_Pred <-cbind(Of_Newdata, Of_Omega_Pred)
  Of_Omega_Pred$Date<-as.Date(as.character(Of_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_of)$coefficients["Year", "Estimate"], digits = 3)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                  #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_Omega_Pred, aes(y = Of_Omega_Pred,
                                      x=Date, colour = Sub_region), linetype=1, size=1)+
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_Omega_Modeled

Oceanic

hist(Trends.ocean$Aragonite_Sat_W)

shapiro.test(Trends.ocean$Aragonite_Sat_W)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$Aragonite_Sat_W
## W = 0.9889, p-value = 0.2355
Omega_oc_0<-lmer(Aragonite_Sat_W ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)

Omega_oc_1<-lmer(Aragonite_Sat_W ~ Year * Sub_region * Season++ (1|SiteID),
               data=Trends.ocean)
  #summary(Omega_oc_0)
  #summary(Omega_oc_1)    
  #anova(Omega_oc_1) 
  anova(Omega_oc_0)
  ranova(Omega_oc_0)
  step(Omega_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 57.434 -96.867                         
## (1 | SiteID)          1    8 57.434 -98.867  0.000  1     0.9999    
## (1 | Month)           0    7 28.818 -43.635 57.232  1  3.873e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1 0.00575 0.00287     2 144.13  0.1464    0.8640    
## Sub_region               2 0.06918 0.03459     2 146.00  1.7828    0.1718    
## Year                     0 0.54008 0.54008     1 156.35 27.5477 4.925e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + (1 | Month)
Omega_oc<-lmer(Aragonite_Sat_W ~ Year + (1 | Month), data = Trends.ocean)
  summary(Omega_oc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Aragonite_Sat_W ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -135.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.4346 -0.6808  0.0680  0.5175  2.4440 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.01649  0.1284  
##  Residual             0.01961  0.1400  
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  69.402759  12.504422 156.361546   5.550 1.19e-07 ***
## Year         -0.032522   0.006196 156.354492  -5.249 4.92e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(Omega_oc)
  plot(Omega_oc)

  qqnorm(resid(Omega_oc))

  acf(resid(Omega_oc), main="acf(resid(Omega open))")

  Arg_oc.emmc<-emmeans(Omega_oc, ~Year)
    #Arg_oc.emmc<-multcomp::cld(Arg_oc.emmc)
    #Arg_oc.emmc<-as.data.frame(Arg_in.emmc[complete.cases(Arg_in.emmc),])
    #Arg_oc.emmc<-Arg_oc.emmc[order(Arg_oc.emmc$Sub_region),]
    #Arg_oc.emmc
# Create a new data frame for independent variables  
  Oc_Newdata<-expand.grid(one=unique(Trends.ocean$Zone),
                                Sub_region=unique(Trends.ocean$Sub_region),
                          Year=seq((min(Trends.ocean$Year)-0), (max(Trends.ocean$Year)+1)))
  Oc_Omega_Pred <- predict(Omega_oc, newdata=Oc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Oc_Omega_Pred <-cbind(Oc_Newdata, Oc_Omega_Pred)
  Oc_Omega_Pred$Date<-as.Date(as.character(Oc_Omega_Pred$Year), format = "%Y")
  
# Model summary for labels
  slope<-round(summary(Omega_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$Aragonite_Sat_W, na.rm =T)
  ys <- max(Trends.offshore$Aragonite_Sat_W, na.rm =T)
  plot_label <- sprintf("\"\" ~ Omega[Ar] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  
  Oc_Omega_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(#limits = c(15,40),
                       #name=(expression("Aragonite saturation state" ~(Omega[Ar]))),
                      name=(expression(~Omega[Ar])),
                       limits = c(3, 4.5),
                       breaks = seq(0, 10, 0.5),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=Aragonite_Sat_W, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region), 
                               alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_Omega_Pred, aes(y = Oc_Omega_Pred,
                                      x=Date), linetype=1, size=1, colour = "black") +
    
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Oc_Omega_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.Omega_in_0 <- data.frame (anova(Omega_in_0))
    av.Omega_mc_0 <- data.frame (anova(Omega_mc_0) )
    av.Omega_of_0 <- data.frame (anova(Omega_of_0))
    av.Omega_oc_0 <- data.frame (anova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    anova_Omega_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.Omega_in_0, av.Omega_mc_0,
                                            av.Omega_of_0, av.Omega_oc_0))) 
    colnames(anova_Omega_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    anova_Omega_0 %>% kable("html", digits=2, 
        caption="Initial omega models fixed factors: Year*Region") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models fixed factors: Year*Region
Sum Sq Mean Sq N Df D Df F value Pr(>F)
Omega inshore
Year 0.14 0.14 1 355.21 1.24 0.27
Sub_region 0.06 0.02 3 347.58 0.19 0.90
Year:Sub_region 0.06 0.02 3 347.57 0.19 0.90
Omega mid-channel
Year 0.30 0.30 1 333.24 5.30 0.02
Sub_region 0.13 0.04 3 323.51 0.77 0.51
Year:Sub_region 0.13 0.04 3 323.51 0.77 0.51
Omega offshore
Year 0.99 0.99 1 408.07 42.77 0.00
Sub_region 0.05 0.02 3 397.30 0.70 0.55
Year:Sub_region 0.05 0.02 3 397.30 0.69 0.56
Omega ocean
Year 0.51 0.51 1 151.91 26.14 0.00
Sub_region 0.01 0.00 2 144.15 0.15 0.86
Year:Sub_region 0.01 0.00 2 144.16 0.15 0.86
# R-ANOVAs    
    rav.Omega_in_0 <- data.frame (ranova(Omega_in_0))
    rav.Omega_mc_0 <- data.frame (ranova(Omega_mc_0) )
    rav.Omega_of_0 <- data.frame (ranova(Omega_of_0))
    rav.Omega_oc_0 <- data.frame (ranova(Omega_oc_0))
    
    # Putting all into one dataframe/table
    ranova_Omega_0 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.Omega_in_0, rav.Omega_mc_0,
                            rav.Omega_of_0, rav.Omega_oc_0))) 
    colnames(ranova_Omega_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_Omega_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_Omega_0 %>% kable("html", digits=2,
         caption="Initial omega models random factors: Month+Station") %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
Initial omega models random factors: Month+Station
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -158.47 338.94
(1 | Month) 10 -292.29 604.58 267.64 1 0.00
(1 | SiteID) 10 -159.73 339.47 2.53 1 0.11
Omega mid-channel
<none> 11 -33.11 88.21
(1 | Month) 10 -102.37 224.74 138.53 1 0.00
(1 | SiteID) 10 -33.64 87.27 1.06 1 0.30
Omega offshore
<none> 11 153.65 -285.30
(1 | Month) 10 86.50 -152.99 134.31 1 0.00
(1 | SiteID) 10 153.49 -286.97 0.33 1 0.56
Omega ocean
<none> 9 57.43 -96.87
(1 | Month) 8 28.82 -41.64 57.23 1 0.00
(1 | SiteID) 8 57.43 -98.87 0.00 1 1.00
Omega_models_0<-list("Inshore" = Omega_in_0, 
                   "Mid channel" = Omega_mc_0, 
                   "Offshore" = Omega_of_0, 
                   "Ocean" = Omega_oc_0)
modelsummary(Omega_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Initial Omega model outputs (all factors)',
             coef_map=factor_order)
Initial Omega model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.021 −0.022 −0.030** −0.038**
(0.020) (0.014) (0.009) (0.013)
Intercept 45.736 48.779+ 64.605*** 80.284**
(39.883) (28.977) (18.437) (25.914)
Upper Keys −13.532 16.828 −7.316
(51.587) (40.622) (23.282)
Middle Keys −31.215 −22.537 10.487 −10.925
(50.015) (36.040) (23.075) (30.349)
Lower Keys −32.891 −35.223 −16.918 −16.583
(50.313) (36.356) (21.984) (30.572)
Num.Obs. 373 348 424 161
R2 Marg. 0.102 0.066 0.111 0.202
R2 Cond. 0.628 0.469 0.441
AIC 338.9 88.2 −285.3 −96.9
BIC 382.1 130.6 −240.8 −69.1
ICC 0.6 0.4 0.4
RMSE 0.32 0.23 0.15 0.13
+ p
#modelsummary(Omega_models, estimate = "p.value")

Models with non-significant factors removed

Omega_models<-list("Inshore" = Omega_in, 
                   "Mid channel" = Omega_mc, 
                   "Offshore" = Omega_of, 
                   "Ocean" = Omega_oc)
modelsummary(Omega_models, stars = TRUE, 
            #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'Final Omega model outputs (dropped factors)',
             coef_map=factor_order)
Final Omega model outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year −0.015* −0.028*** −0.033***
(0.007) (0.004) (0.006)
Intercept 3.632*** 34.412* 59.846*** 69.403***
(0.118) (14.931) (8.611) (12.504)
Upper Keys 0.200*** 0.116** 0.020
(0.052) (0.042) (0.024)
Middle Keys 0.099+ 0.065+ 0.017
(0.051) (0.037) (0.023)
Lower Keys −0.246*** −0.085* −0.062**
(0.051) (0.037) (0.022)
Num.Obs. 373 348 424 161
R2 Marg. 0.102 0.064 0.109 0.110
R2 Cond. 0.617 0.459 0.435 0.517
AIC 308.1 64.3 −313.4 −127.6
BIC 331.7 91.3 −285.0 −115.3
ICC 0.6 0.4 0.4 0.5
RMSE 0.33 0.23 0.15 0.13
+ p
modelsummary(Omega_models, output = "FLK_results/Figures/Fig_2/Trend_Omega.docx")
#modelsummary(Omega_models, estimate = "p.value")
Trends_Omega<-ggarrange(In_Omega_Modeled+ theme(
                                          #axis.text.x=element_blank(),
                                          legend.position = "none"),
                  Mc_Omega_Modeled+ theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Of_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                
                  Oc_Omega_Modeled + theme(legend.position = "none",
                                           #axis.text.x=element_blank(),
                                           axis.title.y=element_blank()),
                                           
          labels = c("C"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_Omega

pCO2-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pCO2_uatm
## W = 0.96584, p-value < 2.2e-16

## Model with all data
pCO2_all_o<-lmer(pCO2_uatm~Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(Omega_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 -319.09  704.18                         
## (1 | SiteID)          1   32 -319.34  702.67   0.49  1     0.4849    
## (1 | Month)           0   31 -506.30 1074.59 373.92  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)
## Year:Zone:Sub_region          1 0.1753 0.02192     8 1265.1  0.2644  0.97717
## Year:Sub_region               2 0.1009 0.03364     3 1273.3  0.4077  0.74747
## Year:Zone                     0 0.6658 0.22195     3 1276.1  2.6936  0.04482
## Zone:Sub_region               0 5.4769 0.68461     8 1276.1  8.3088 4.94e-11
##                         
## Year:Zone:Sub_region    
## Year:Sub_region         
## Year:Zone            *  
## Zone:Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## Aragonite_Sat_W ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pCO2_all_o_1<-lmer(pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pCO2_all_o_3<-lmer(pCO2_uatm ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pCO2_all_o, pCO2_all_o_1, pCO2_all_o_3)
    summary(pCO2_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: 13976.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.3622 -0.5534 -0.0761  0.5213  5.6841 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 2727     52.22   
##  Residual             2721     52.17   
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   -2370.784   2838.709   1280.456  -0.835 0.403782
## Year                              1.394      1.407   1280.396   0.991 0.321990
## ZoneMid channel               -5726.375   3867.277   1276.066  -1.481 0.138927
## ZoneOffshore                 -10230.979   3684.011   1276.079  -2.777 0.005564
## ZoneOceanic                  -13407.538   4861.031   1275.987  -2.758 0.005896
## Sub_regionUK                    -26.986      8.171   1275.986  -3.303 0.000984
## Sub_regionMK                    -29.743      8.002   1275.980  -3.717 0.000210
## Sub_regionLK                      8.370      7.957   1275.988   1.052 0.293031
## Year:ZoneMid channel              2.828      1.916   1276.066   1.476 0.140219
## Year:ZoneOffshore                 5.059      1.826   1276.079   2.771 0.005664
## Year:ZoneOceanic                  6.629      2.409   1275.987   2.752 0.006008
## ZoneMid channel:Sub_regionUK     15.346     12.186   1275.996   1.259 0.208144
## ZoneOffshore:Sub_regionUK        22.302     11.459   1275.981   1.946 0.051846
## ZoneOceanic:Sub_regionUK         26.092     13.810   1275.998   1.889 0.059066
## ZoneMid channel:Sub_regionMK     17.202     11.313   1275.959   1.521 0.128629
## ZoneOffshore:Sub_regionMK        22.904     11.279   1275.960   2.031 0.042497
## ZoneOceanic:Sub_regionMK         32.224     11.624   1275.968   2.772 0.005651
## ZoneMid channel:Sub_regionLK     -3.244     11.259   1275.957  -0.288 0.773308
## ZoneOffshore:Sub_regionLK        -5.120     10.958   1275.960  -0.467 0.640369
##                                 
## (Intercept)                     
## Year                            
## ZoneMid channel                 
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 ***
## Sub_regionLK                    
## Year:ZoneMid channel            
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    .  
## ZoneOceanic:Sub_regionUK     .  
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK    *  
## ZoneOceanic:Sub_regionMK     ** 
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pCO2_all_o_1)
    ranova(pCO2_all_o_1)
# Obtain slopes
    
    ranef(pCO2_all_o_1)
## $Month
##     (Intercept)
## Apr  -63.065458
## May  -60.058921
## Jun    4.230287
## Jul   56.360019
## Aug   26.407851
## Sep   78.531848
## Oct   41.719135
## Nov   54.666768
## Dec   -8.519955
## Jan  -13.722468
## Feb  -69.453622
## Mar  -47.095484
## 
## with conditional variances for "Month"
    fixef(pCO2_all_o_1)
##                  (Intercept)                         Year 
##                 -2370.784285                     1.393637 
##              ZoneMid channel                 ZoneOffshore 
##                 -5726.374554                -10230.978644 
##                  ZoneOceanic                 Sub_regionUK 
##                -13407.538357                   -26.986185 
##                 Sub_regionMK                 Sub_regionLK 
##                   -29.742977                     8.370348 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                     2.828433                     5.059307 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                     6.629285                    15.346269 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                    22.301737                    26.091559 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                    17.201669                    22.903774 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                    32.223667                    -3.243754 
##    ZoneOffshore:Sub_regionLK 
##                    -5.120408
    coef(pCO2_all_o_1)$Month
    coef(pCO2_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pCO2_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend   SE   df lower.CL upper.CL
##  Inshore           1.39 1.41 1280    -1.37     4.15
##  Mid channel       4.22 1.45 1280     1.38     7.07
##  Offshore          6.45 1.33 1280     3.85     9.05
##  Oceanic           8.02 2.05 1278     4.00    12.05
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate   SE   df t.ratio p.value
##  Inshore - Mid channel     -2.83 1.92 1276  -1.476  0.4524
##  Inshore - Offshore        -5.06 1.83 1276  -2.771  0.0289
##  Inshore - Oceanic         -6.63 2.41 1276  -2.752  0.0306
##  Mid channel - Offshore    -2.23 1.86 1276  -1.199  0.6274
##  Mid channel - Oceanic     -3.80 2.43 1276  -1.561  0.4014
##  Offshore - Oceanic        -1.57 2.36 1276  -0.664  0.9106
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates

Inshore

# Inshore pCO2
  hist(Trends.inshore$pCO2_uatm)

  shapiro.test(Trends.inshore$pCO2_uatm)# Normality NOT? rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pCO2_uatm
## W = 0.99227, p-value = 0.0502
  pCO2_in_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(pCO2_in_0)    
  anova(pCO2_in_0)
  ranova(pCO2_in_0)
  step(pCO2_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2081.9 4185.7                          
## (1 | Month)           0   10 -2239.1 4498.2 314.514  1    < 2e-16 ***
## (1 | SiteID)          0   10 -2084.8 4189.7   5.948  1    0.01473 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Year:Sub_region          1 11398.4  3799.5     3 347.42  0.9312 0.4257
## Year                     2  3465.1  3465.1     1 356.71  0.8494 0.3573
## Sub_region               3 30987.8 10329.3     3   6.99  2.5318 0.1406
## 
## Model found:
## pCO2_uatm ~ (1 | Month) + (1 | SiteID)
pCO2_in<-lmer(pCO2_uatm ~ (1|Month)+(1|SiteID), data=Trends.inshore)
  summary(pCO2_in)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4212.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6141 -0.6364 -0.0455  0.5782  3.8147 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 7423     86.16   
##  SiteID   (Intercept)  395     19.88   
##  Residual             4079     63.87   
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   427.28      25.82  12.22   16.55 9.77e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  anova(pCO2_in)
  plot(pCO2_in)

  qqnorm(resid(pCO2_in))

  acf(resid(pCO2_in), main="acf(resid(pCO2 Inshore))")  

  #pCO2_in.emmc<-emmeans(pCO2_in, ~Month)
      #pCO2_in.emmc<-multcomp::cld(pCO2_in.emmc)
      #pCO2_in.emmc<-pCO2_in.emmc[order(pCO2_in.emmc$Sub_region),]
      #pCO2_in.emmc
# Predict values  
  In_pCO2_Pred <- predict(pCO2_in, newdata=In_Newdata, re.form=NA, level=0, asList = FALSE)
  
  In_pCO2_Pred <-cbind(In_Newdata, In_pCO2_Pred)
  In_pCO2_Pred$Date<-as.Date(as.character(In_pCO2_Pred$Year), format = "%Y")
  
# # Model summary
#   slope<-round(
#       summary(pCO2_in)$coefficients["Year", "Estimate"], digits = 3)
#   xs <- as.Date(as.character("2018-11-20"))
#   ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)
# 
# # Plot raw data point and fitted model 
#   plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
#   plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  In_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                        limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                  alpha=0.5, size=0.5, shape=21)+
      geom_line(data=In_pCO2_Pred, aes(y = In_pCO2_Pred,
                                      x=Date), linetype=2, size=1, colour = "black")

  In_pCO2_Modeled

Mid channel

hist(Trends.midchanel$pCO2_uatm)

shapiro.test(Trends.midchanel$pCO2_uatm)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pCO2_uatm
## W = 0.99235, p-value = 0.07115
pCO2_mc_0<-lmer(pCO2_uatm~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(pCO2_mc_0)    
  anova(pCO2_mc_0)
  ranova(pCO2_mc_0)
  step(pCO2_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1786.3 3594.5                          
## (1 | SiteID)          1   10 -1786.5 3592.9   0.361  1     0.5477    
## (1 | Month)           0    9 -1908.4 3834.8 243.885  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1  6492.3  2164.1     3 328.96  1.2852 0.279385   
## Year                     0 16354.6 16354.6     1 338.48  9.6873 0.002014 **
## Sub_region               0 21649.6  7216.5     3 332.02  4.2746 0.005584 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month)
pCO2_mc<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month), 
              data = Trends.midchanel)
  summary(pCO2_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3588.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8746 -0.5794 -0.1050  0.5867  4.2643 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 2567     50.66   
##  Residual             1688     41.09   
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  -7606.989   2580.295   338.502  -2.948  0.00342 **
## Year             3.979      1.279   338.483   3.112  0.00201 **
## Sub_regionUK   -11.913      7.130   332.019  -1.671  0.09570 . 
## Sub_regionMK   -12.236      6.310   331.987  -1.939  0.05331 . 
## Sub_regionLK     5.362      6.297   332.030   0.851  0.39514   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.017  0.532  0.601
   anova(pCO2_mc)
   plot(pCO2_mc)

  qqnorm(resid(pCO2_mc))

  acf(resid(pCO2_mc), main="acf(resid(pCO2 Mid Channel))")  

  pCO2_mc.emmc<-emmeans(pCO2_mc, ~Sub_region+Year)
        pCO2_mc.emmc<-multcomp::cld(pCO2_mc.emmc)
        pCO2_mc.emmc<-pCO2_mc.emmc[order(
          pCO2_mc.emmc$Sub_region),]
  pCO2_mc.emmc
  #write.csv(pCO2_mc.emmc, "FLK_results/Model_2_LTpCO2_POST.csv")
# Predict values  
  Mc_pCO2_Pred <- predict(pCO2_mc, newdata=Mc_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Mc_pCO2_Pred <-cbind(Mc_Newdata, Mc_pCO2_Pred)
  Mc_pCO2_Pred$Date<-as.Date(as.character(Mc_pCO2_Pred$Year), format = "%Y")
  
 # Model summary
  slope<-round(
      summary(pCO2_mc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pCO2_uatm, na.rm =T)
  ys <- max(Trends.midchanel$pCO2_uatm, na.rm =T)+50

# Plot raw data point and fitted model 
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
  
# Plot raw data point and fitted model 
  
  Mc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(200,800),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pCO2_Pred, aes(y = Mc_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Mc_pCO2_Modeled

Offshore

hist(Trends.offshore$pCO2_uatm)

shapiro.test(Trends.offshore$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pCO2_uatm
## W = 0.94091, p-value = 6.045e-12
pCO2_of_0<-lmer(pCO2_uatm~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pCO2_of_0)    
  anova(pCO2_of_0)
  ranova(pCO2_of_0)
  step(pCO2_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -2035.5 4092.9                         
## (1 | SiteID)          1   10 -2035.5 4090.9   0.00  1     0.9999    
## (1 | Month)           0    9 -2178.9 4375.8 286.89  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   3276    1092     3 404.84  1.2925   0.27657    
## Year                     0  54912   54912     1 414.03 64.8508 8.678e-15 ***
## Sub_region               0   9100    3033     3 407.84  3.5822   0.01397 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + Sub_region + (1 | Month)
pCO2_of<-lmer(pCO2_uatm ~ Year + Sub_region + (1 | Month),
              data =Trends.offshore)
  summary(pCO2_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 4083.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6834 -0.6495 -0.0985  0.5935  4.4101 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1413.8   37.6    
##  Residual              846.7   29.1    
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  -1.290e+04  1.655e+03  4.141e+02  -7.798 5.16e-14 ***
## Year          6.603e+00  8.199e-01  4.140e+02   8.053 8.68e-15 ***
## Sub_regionUK -3.165e+00  4.482e+00  4.078e+02  -0.706    0.481    
## Sub_regionMK -7.104e+00  4.438e+00  4.078e+02  -1.601    0.110    
## Sub_regionLK  4.680e+00  4.220e+00  4.079e+02   1.109    0.268    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.014  0.012  0.623  0.630
  anova(pCO2_of)
  plot(pCO2_of)

  qqnorm(resid(pCO2_of))

  acf(resid(Omega_in), main="acf(resid(pCO2 Offshore))")  

  pCO2_of.emmc<-emmeans(pCO2_of, ~Sub_region)
        pCO2_of.emmc<-multcomp::cld(pCO2_of.emmc)
        pCO2_of.emmc<-pCO2_of.emmc[order(pCO2_of.emmc$Sub_region),]
  pCO2_of.emmc
  #write.csv(pCO2_of.emmc, "FLK_results/Model_3_LTpCO2_POST.csv")
# Predict values  
  Of_pCO2_Pred <- predict(pCO2_of, newdata=Of_Newdata, re.form=NA, level=0, asList = FALSE)
  
  Of_pCO2_Pred <-cbind(Of_Newdata, Of_pCO2_Pred)
  Of_pCO2_Pred$Date<-as.Date(as.character(Of_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_of)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T) -15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Of_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pCO2_uatm, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pCO2_Pred, aes(y = Of_pCO2_Pred,
                                      x=Date, colour = Sub_region),
                linetype=1, size=1) +
     annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
               #label = expression("~Omega[Ar] == -0.015** ~Year ^-1"), 
               label =paste0(as.character(plot_label, plot_label2, sep = " ")),
               size=4)
  Of_pCO2_Modeled

Oceanic

hist(Trends.ocean$pCO2_uatm)

shapiro.test(Trends.ocean$pCO2_uatm)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pCO2_uatm
## W = 0.9089, p-value = 1.793e-08
pCO2_oc_0<-lmer(pCO2_uatm ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pCO2_oc_0)    
  anova(pCO2_oc_0)
  ranova(pCO2_oc_0)
  step(pCO2_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -763.72 1545.4                         
## (1 | SiteID)          1    8 -763.72 1543.4  0.000  1          1    
## (1 | Month)           0    7 -793.09 1600.2 58.747  1  1.793e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1    77.9    39.0     2 143.41  0.0503    0.9510    
## Sub_region               2  1222.5   611.3     2 145.31  0.7992    0.4517    
## Year                     0 26011.6 26011.6     1 155.26 34.0692 3.005e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pCO2_uatm ~ Year + (1 | Month)
pCO2_oc<-lmer(pCO2_uatm ~ Year + (1 | Month), 
              data = Trends.ocean)
  summary(pCO2_oc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pCO2_uatm ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1546.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.3192 -0.6292 -0.1467  0.5901  2.8224 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 773.6    27.81   
##  Residual             763.5    27.63   
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept) -14025.177   2474.792    155.267  -5.667 6.87e-08 ***
## Year             7.158      1.226    155.259   5.837 3.01e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pCO2_oc) 
  plot(pCO2_oc)

  qqnorm(resid(pCO2_oc))

  acf(resid(pCO2_oc), main="acf(resid(pCO2 open))")

  pCO2_oc.emmc<-emmeans(pCO2_oc, ~Year)
        pCO2_oc.emmc<-multcomp::cld(pCO2_oc.emmc)
        #pCO2_oc.emmc<-pCO2_oc.emmc[order(pCO2_oc.emmc$Sub_region),]
  pCO2_oc.emmc
# Predict values  
  Oc_pCO2_Pred <- predict(pCO2_oc, newdata=Oc_Newdata, 
                          re.form=NA, level=0, asList = FALSE)
  Oc_pCO2_Pred <-cbind(Oc_Newdata, Oc_pCO2_Pred)
  Oc_pCO2_Pred$Date<-as.Date(as.character(Oc_pCO2_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pCO2_oc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  ys <- max(Trends.offshore$pCO2_uatm, na.rm =T)-15
  plot_label <- sprintf("\"\" ~ pCO[2] == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Oc_pCO2_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=expression(paste(pCO[2], ~" (", mu, " atm)")),
                       limits = c(300,605),
                        breaks = seq(0, 800, 100),  
                        expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pCO2_uatm, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pCO2_Pred, aes(y = Oc_pCO2_Pred, x=Date), 
                          colour = "black", linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
              label =paste0(as.character(plot_label, plot_label2, sep = " ")),
              size=4)
  Oc_pCO2_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    
    av.pCO2_in_0 <- data.frame (anova(pCO2_in_0))
    av.pCO2_mc_0 <- data.frame (anova(pCO2_mc_0) )
    av.pCO2_of_0 <- data.frame (anova(pCO2_of_0))
    av.pCO2_oc_0 <- data.frame (anova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                      rbind(av.pCO2_in_0, av.pCO2_mc_0,
                      av.pCO2_of_0, av.pCO2_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
    
    # create HTML table using kableExtra
    anova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pCO2 inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pCO2 mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pCO2 offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pCO2 ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pCO2 inshore
Year 3827.77 3827.77 1 353.59 0.94 0.33
Sub_region 11443.07 3814.36 3 347.42 0.93 0.42
Year:Sub_region 11398.40 3799.47 3 347.42 0.93 0.43
pCO2 mid-channel
Year 17990.76 17990.76 1 330.00 10.76 0.00
Sub_region 6574.85 2191.62 3 323.66 1.31 0.27
Year:Sub_region 6555.91 2185.30 3 323.66 1.31 0.27
pCO2 offshore
Year 56531.62 56531.62 1 410.81 66.90 0.00
Sub_region 3285.48 1095.16 3 404.82 1.30 0.28
Year:Sub_region 3276.20 1092.07 3 404.82 1.29 0.28
pCO2 ocean
Year 23313.90 23313.90 1 150.81 30.07 0.00
Sub_region 78.50 39.25 2 143.45 0.05 0.95
Year:Sub_region 77.93 38.97 2 143.45 0.05 0.95
# R-ANOVAs    
    rav.pCO2_in_0 <- data.frame (ranova(pCO2_in_0))
    rav.pCO2_mc_0 <- data.frame (ranova(pCO2_mc_0) )
    rav.pCO2_of_0 <- data.frame (ranova(pCO2_of_0))
    rav.pCO2_oc_0 <- data.frame (ranova(pCO2_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pCO2 <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pCO2_in_0, rav.pCO2_mc_0,
                            rav.pCO2_of_0, rav.pCO2_oc_0))) 
    colnames(ranova_pCO2) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pCO2) <- NULL
    
    # create HTML table using kableExtra
    ranova_pCO2 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "Omega inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "Omega mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "Omega offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "Omega ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
Omega inshore
<none> 11 -2081.86 4185.72
(1 | Month) 10 -2239.12 4498.23 314.51 1 0.00
(1 | SiteID) 10 -2084.83 4189.66 5.95 1 0.01
Omega mid-channel
<none> 11 -1786.27 3594.53
(1 | Month) 10 -1908.39 3836.78 244.25 1 0.00
(1 | SiteID) 10 -1786.45 3592.90 0.36 1 0.55
Omega offshore
<none> 11 -2035.47 4092.93
(1 | Month) 10 -2178.91 4377.82 286.89 1 0.00
(1 | SiteID) 10 -2035.47 4090.93 0.00 1 1.00
Omega ocean
<none> 9 -763.72 1545.43
(1 | Month) 8 -793.09 1602.18 58.75 1 0.00
(1 | SiteID) 8 -763.72 1543.43 0.00 1 1.00
pCO2_models_0<-list("Inshore" = pCO2_in_0, 
                   "Mid channel" = pCO2_mc_0, 
                   "Offshore" = pCO2_of_0, 
                   "Ocean" = pCO2_oc_0)
modelsummary(pCO2_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO model outputs (all factors)',
             coef_map=factor_order)
pCO model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 3.785 5.358* 7.884*** 7.146**
(3.814) (2.472) (1.747) (2.554)
Intercept −7198.143 −10388.175* −15489.367*** −14002.750**
(7696.751) (4988.665) (3524.582) (5153.529)
Upper Keys 3479.625 −1169.721 2812.235
(9952.365) (6981.992) (4442.947)
Middle Keys −899.345 721.299 −512.538 −720.552
(9648.005) (6194.920) (4403.595) (6031.071)
Lower Keys 12648.581 9366.041 6102.617 816.986
(9705.503) (6249.496) (4195.522) (6074.570)
Num.Obs. 373 348 424 161
R2 Marg. 0.024 0.033 0.198 0.225
R2 Cond. 0.665 0.620
AIC 4185.7 3594.5 4092.9 1545.4
BIC 4228.9 3636.9 4137.5 1573.2
ICC 0.7 0.6
RMSE 61.84 39.68 28.42 26.41
+ p
#modelsummary(Omega_models, estimate = "p.value")

Factors removed models

pCO2_models<-list("Inshore" = pCO2_in, 
                   "Mid channel" = pCO2_mc, 
                   "Offshore" = pCO2_of, 
                   "Ocean" = pCO2_oc)
modelsummary(pCO2_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pCO2 models outputs (dropped factors)',
             coef_map=factor_order)
pCO2 models outputs (dropped factors)
Inshore Mid channel Offshore Ocean
Year 3.979** 6.603*** 7.158***
(1.279) (0.820) (1.226)
Intercept 427.280*** −7606.989** −12902.943*** −14025.177***
(25.822) (2580.295) (1654.695) (2474.792)
Upper Keys −11.913+ −3.165
(7.130) (4.482)
Middle Keys −12.236+ −7.103
(6.310) (4.438)
Lower Keys 5.362 4.680
(6.297) (4.219)
Num.Obs. 373 348 424 161
R2 Marg. 0.000 0.029 0.082 0.123
R2 Cond. 0.657 0.615 0.656 0.565
AIC 4220.8 3602.4 4097.8 1554.9
BIC 4236.5 3629.4 4126.2 1567.2
ICC 0.7 0.6 0.6 0.5
RMSE 62.18 40.15 28.55 26.57
+ p
#modelsummary(pCO2_models, estimate = "p.value")
Trends_pCO2<-ggarrange(In_pCO2_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pCO2_Modeled + theme(legend.position = "none",
                                 axis.title.y=element_blank(),
                                 axis.text.x=element_blank()),
                                
                  Of_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                                
                  Oc_pCO2_Modeled + theme(legend.position = "none",
                                           axis.title.y=element_blank(),
                                           axis.text.x=element_blank()),
                  
          labels = c("A"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pCO2

pH-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$pH_calculated
## W = 0.97877, p-value = 6.115e-13

## Model with all data
pH_all_o<-lmer(pH_calculated ~ Year * Zone * Sub_region + (1|Month)+           
                                    (1|SiteID), data=Trends.data)
    step(pH_all_o)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    33 2114.1 -4162.2                         
## (1 | SiteID)          1   32 2113.0 -4162.1   2.14  1     0.1432    
## (1 | Month)           0   31 1697.5 -3333.0 831.12  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                      Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value
## Year:Zone:Sub_region          1 0.002341 0.0002926     8 1264.9  0.1612
## Year:Sub_region               2 0.010214 0.0034048     3 1273.2  1.8859
## Year:Zone                     0 0.027362 0.0091205     3 1276.0  5.0413
## Zone:Sub_region               0 0.057144 0.0071431     8 1276.0  3.9483
##                         Pr(>F)    
## Year:Zone:Sub_region 0.9956439    
## Year:Sub_region      0.1300852    
## Year:Zone            0.0017821 ** 
## Zone:Sub_region      0.0001255 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone + Zone:Sub_region
pH_all_o_1<-lmer(pH_calculated ~ Year + Zone + Sub_region + (1 | Month) +
                      Year:Zone + Zone:Sub_region, data=Trends.data)

pH_all_o_3<-lmer(pH_calculated ~ Year + Zone + (1 | Month) + (1|Sub_region)+
                       Year:Zone, data=Trends.data)
    

anova(pH_all_o, pH_all_o_1, pH_all_o_3)
    summary(pH_all_o_1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Zone + Sub_region + (1 | Month) + Year:Zone +  
##     Zone:Sub_region
##    Data: Trends.data
## 
## REML criterion at convergence: -4327.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0984 -0.5453  0.0507  0.5325  4.6588 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.002210 0.04701 
##  Residual             0.001809 0.04253 
## Number of obs: 1306, groups:  Month, 12
## 
## Fixed effects:
##                                Estimate Std. Error         df t value Pr(>|t|)
## (Intercept)                   7.757e+00  2.315e+00  1.280e+03   3.351 0.000829
## Year                          1.329e-04  1.147e-03  1.280e+03   0.116 0.907769
## ZoneMid channel               5.458e+00  3.153e+00  1.276e+03   1.731 0.083704
## ZoneOffshore                  9.877e+00  3.004e+00  1.276e+03   3.288 0.001036
## ZoneOceanic                   1.269e+01  3.963e+00  1.276e+03   3.202 0.001399
## Sub_regionUK                  2.421e-02  6.662e-03  1.276e+03   3.634 0.000291
## Sub_regionMK                  1.660e-02  6.524e-03  1.276e+03   2.545 0.011051
## Sub_regionLK                 -2.231e-02  6.488e-03  1.276e+03  -3.438 0.000605
## Year:ZoneMid channel         -2.700e-03  1.563e-03  1.276e+03  -1.728 0.084206
## Year:ZoneOffshore            -4.889e-03  1.489e-03  1.276e+03  -3.285 0.001048
## Year:ZoneOceanic             -6.273e-03  1.964e-03  1.276e+03  -3.194 0.001439
## ZoneMid channel:Sub_regionUK -1.280e-02  9.936e-03  1.276e+03  -1.288 0.197859
## ZoneOffshore:Sub_regionUK    -2.099e-02  9.343e-03  1.276e+03  -2.247 0.024822
## ZoneOceanic:Sub_regionUK     -3.802e-02  1.126e-02  1.276e+03  -3.377 0.000755
## ZoneMid channel:Sub_regionMK -8.770e-03  9.224e-03  1.276e+03  -0.951 0.341895
## ZoneOffshore:Sub_regionMK    -1.245e-02  9.196e-03  1.276e+03  -1.354 0.175919
## ZoneOceanic:Sub_regionMK     -3.365e-02  9.478e-03  1.276e+03  -3.550 0.000398
## ZoneMid channel:Sub_regionLK  1.285e-02  9.180e-03  1.276e+03   1.400 0.161896
## ZoneOffshore:Sub_regionLK     1.862e-02  8.934e-03  1.276e+03   2.084 0.037377
##                                 
## (Intercept)                  ***
## Year                            
## ZoneMid channel              .  
## ZoneOffshore                 ** 
## ZoneOceanic                  ** 
## Sub_regionUK                 ***
## Sub_regionMK                 *  
## Sub_regionLK                 ***
## Year:ZoneMid channel         .  
## Year:ZoneOffshore            ** 
## Year:ZoneOceanic             ** 
## ZoneMid channel:Sub_regionUK    
## ZoneOffshore:Sub_regionUK    *  
## ZoneOceanic:Sub_regionUK     ***
## ZoneMid channel:Sub_regionMK    
## ZoneOffshore:Sub_regionMK       
## ZoneOceanic:Sub_regionMK     ***
## ZoneMid channel:Sub_regionLK    
## ZoneOffshore:Sub_regionLK    *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## fit warnings:
## fixed-effect model matrix is rank deficient so dropping 1 column / coefficient
    anova(pH_all_o_1)
    ranova(pH_all_o_1)
    ranef(pH_all_o_1)
## $Month
##      (Intercept)
## Apr  0.054975419
## May  0.049160922
## Jun -0.013467739
## Jul -0.055830887
## Aug -0.032931185
## Sep -0.065502539
## Oct -0.034828359
## Nov -0.040939492
## Dec  0.008610227
## Jan  0.016861511
## Feb  0.068036630
## Mar  0.045855491
## 
## with conditional variances for "Month"
    fixef(pH_all_o_1)
##                  (Intercept)                         Year 
##                 7.7571304554                 0.0001329224 
##              ZoneMid channel                 ZoneOffshore 
##                 5.4580497593                 9.8770992079 
##                  ZoneOceanic                 Sub_regionUK 
##                12.6907155256                 0.0242072024 
##                 Sub_regionMK                 Sub_regionLK 
##                 0.0166026830                -0.0223062905 
##         Year:ZoneMid channel            Year:ZoneOffshore 
##                -0.0027003365                -0.0048895011 
##             Year:ZoneOceanic ZoneMid channel:Sub_regionUK 
##                -0.0062730790                -0.0128011155 
##    ZoneOffshore:Sub_regionUK     ZoneOceanic:Sub_regionUK 
##                -0.0209924076                -0.0380242862 
## ZoneMid channel:Sub_regionMK    ZoneOffshore:Sub_regionMK 
##                -0.0087702108                -0.0124536166 
##     ZoneOceanic:Sub_regionMK ZoneMid channel:Sub_regionLK 
##                -0.0336516270                 0.0128475157 
##    ZoneOffshore:Sub_regionLK 
##                 0.0186174248
    coef(pH_all_o_1)$Month
    coef(pH_all_o_1)$Zone
## NULL
  m.lst <- lstrends(pH_all_o_1, "Zone", var="Year")
  m.lst
##  Zone        Year.trend      SE   df lower.CL  upper.CL
##  Inshore       0.000133 0.00115 1280 -0.00212  0.002384
##  Mid channel  -0.002567 0.00118 1279 -0.00489 -0.000247
##  Offshore     -0.004757 0.00108 1280 -0.00688 -0.002635
##  Oceanic      -0.006140 0.00167 1278 -0.00942 -0.002856
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95
  pairs(m.lst)
##  contrast               estimate      SE   df t.ratio p.value
##  Inshore - Mid channel   0.00270 0.00156 1276   1.728  0.3094
##  Inshore - Offshore      0.00489 0.00149 1276   3.285  0.0058
##  Inshore - Oceanic       0.00627 0.00196 1276   3.194  0.0078
##  Mid channel - Offshore  0.00219 0.00152 1276   1.443  0.4724
##  Mid channel - Oceanic   0.00357 0.00199 1276   1.800  0.2739
##  Offshore - Oceanic      0.00138 0.00193 1276   0.718  0.8901
## 
## Results are averaged over the levels of: Sub_region 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 4 estimates
  # Create a new data frame for independent variables  
  Newdata<-expand.grid(Zone=unique(Trends.data$Zone),
                          Sub_region=unique(Trends.data$Sub_region),
                          Year=seq((min(Trends.data$Year)-0), (max(Trends.data$Year)+1)))
  
  # Predict values  
  pH_Pred <- predict(pH_all_o_1, newdata=Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  pH_Pred <-cbind(Newdata, pH_Pred)
  pH_Pred$Date<-as.Date(as.character(pH_Pred$Year), format = "%Y")
  

pH_Modeled<-Long_plot2+ facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.data, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=pH_Pred, aes(y = pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  pH_Modeled

Inshore

# Inshore pH
hist(Trends.inshore$pH_calculated)

shapiro.test(Trends.inshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$pH_calculated
## W = 0.98963, p-value = 0.009646
pH_in_0<-lmer(pH_calculated~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.inshore)
  #summary(pH_in_0)    
  anova(pH_in_0)
  ranova(pH_in_0)
  step(pH_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC    LRT Df Pr(>Chisq)    
## <none>                    11 518.84 -1015.68                         
## (1 | Month)           0   10 343.63  -667.26 350.42  1    < 2e-16 ***
## (1 | SiteID)          0   10 516.35 -1012.71   4.97  1    0.02574 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated   Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1 0.007655 0.0025518     3 347.54  0.9699 0.40703  
## Year                     2 0.000441 0.0004414     1 356.04  0.1677 0.68239  
## Sub_region               0 0.041536 0.0138455     3   7.03  5.2723 0.03229 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
pH_in<-lmer(pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID),
            data=Trends.inshore)
  summary(pH_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: -1074.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8173 -0.6283 -0.0120  0.5979  3.7926 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0057954 0.07613 
##  SiteID   (Intercept) 0.0001307 0.01143 
##  Residual             0.0026261 0.05125 
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)   8.02708    0.02420 14.58618 331.764   <2e-16 ***
## Sub_regionUK  0.02175    0.01317  7.03024   1.651    0.143    
## Sub_regionMK  0.01695    0.01307  6.82486   1.297    0.237    
## Sub_regionLK -0.02075    0.01305  6.77579  -1.590    0.157    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.318              
## Sub_reginMK -0.321  0.589       
## Sub_reginLK -0.322  0.590  0.595
  anova(pH_in)
  plot(pH_in)

  qqnorm(resid(pH_in))

  acf(resid(pH_in), main="acf(resid(pH Inshore))")  

  pH_in.emmc<-emmeans(pH_in, ~Sub_region)
        pH_in.emmc<-multcomp::cld(pH_in.emmc)
        pH_in.emmc<-pH_in.emmc[order(pH_in.emmc$Sub_region),]
  pH_in.emmc
#write.csv(pH_in.emmc, "FLK_results/Model_5_LTpH_POST.csv")
# Predict values  
  In_pH_Pred <- predict(pH_in, newdata=In_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
    In_pH_Pred <-cbind(In_Newdata, In_pH_Pred)
  In_pH_Pred$Date<-as.Date(as.character(In_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  # slope<-round(
  #     summary(pH_in)$coefficients["Year", "Estimate"], digits = 3)
  # xs <- as.Date(as.character("2018-11-20"))
  # ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  # plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  # plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  In_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.inshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5,shape=21)+
      geom_line(data=In_pH_Pred, aes(y = In_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=2, size=1) #+
      #annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
      #        label =paste0(as.character(plot_label, plot_label2, sep = " ")),
      #        size=4)
  In_pH_Modeled

Mid channel

hist(Trends.midchanel$pH_calculated)

shapiro.test(Trends.midchanel$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$pH_calculated
## W = 0.98753, p-value = 0.004369
pH_mc_0<-lmer(pH_calculated~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(pH_mc_0)    
  anova(pH_mc_0)
  ranova(pH_mc_0)
  step(pH_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik      AIC     LRT Df Pr(>Chisq)    
## <none>                    11 621.59 -1221.18                          
## (1 | SiteID)          1   10 621.36 -1222.72   0.456  1     0.4997    
## (1 | Month)           0    9 484.04  -950.08 274.647  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0041921 0.0013974     3 328.97  1.1815 0.3167596
## Year                     0 0.0056820 0.0056820     1 337.72  4.7964 0.0292023
## Sub_region               0 0.0237637 0.0079212     3 332.00  6.6866 0.0002148
##                    
## Year:Sub_region    
## Year            *  
## Sub_region      ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month)
pH_mc<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month),
            data = Trends.midchanel)
  summary(pH_mc)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: -1270
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5029 -0.6297  0.0278  0.5480  4.0468 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 0.002128 0.04613 
##  Residual             0.001185 0.03442 
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   12.771183   2.163374 337.738692   5.903 8.67e-09 ***
## Year          -0.002348   0.001072 337.716529  -2.190   0.0292 *  
## Sub_regionUK   0.011699   0.005973 332.002681   1.959   0.0510 .  
## Sub_regionMK   0.007645   0.005285 331.975599   1.447   0.1490    
## Sub_regionLK  -0.009538   0.005275 332.012556  -1.808   0.0715 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.017  0.532  0.601
  anova(pH_mc)
  plot(pH_mc)

  qqnorm(resid(pH_mc))

  acf(resid(pH_mc), main="acf(resid(pH Mid Channel))")  

  pH_mc.emmc<-emmeans(pH_mc, ~Sub_region)
        pH_mc.emmc<-multcomp::cld(pH_mc.emmc)
        pH_mc.emmc<-pH_mc.emmc[order(pH_mc.emmc$Sub_region),]
  pH_mc.emmc
  #write.csv(pH_mc.emmc, "FLK_results/Model_6_LTpH_POST.csv")
# Predict values  
  Mc_pH_Pred <- predict(pH_mc, newdata=Mc_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Mc_pH_Pred <-cbind(Mc_Newdata, Mc_pH_Pred)
  Mc_pH_Pred$Date<-as.Date(as.character(Mc_pH_Pred$Year), format = "%Y")
  
# Model summary for slope labels 
  slope<-round(
      summary(pH_mc)$coefficients["Year", "Estimate"], digits = 3)
  #xs <- as.Date(as.character("2018-11-20"))
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.midchanel$pH_calculated, na.rm =T)+0.03
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")
  
# Plot raw data point and fitted model 
  Mc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                       breaks = seq(0, 10, 0.1),  
                       limits=c(7.80, 8.28),
                       expand = c(0.02, 0.02)) +
    
      geom_point(data=Trends.midchanel, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=23)+
      geom_line(data=Mc_pH_Pred, aes(y = Mc_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Mc_pH_Modeled

Offshore

hist(Trends.offshore$pH_calculated)

shapiro.test(Trends.offshore$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$pH_calculated
## W = 0.97503, p-value = 1.157e-06
pH_of_0<-lmer(pH_calculated~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(pH_of_0)    
  anova(pH_of_0)
  ranova(pH_of_0)
  step(pH_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                    11 929.90 -1837.8                         
## (1 | SiteID)          1   10 929.90 -1839.8   0.00  1          1    
## (1 | Month)           0    9 762.18 -1506.3 335.44  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0025882 0.0008627     3 404.84  1.5961   0.18976
## Year                     0 0.0270864 0.0270864     1 413.06 49.8921 6.937e-12
## Sub_region               0 0.0057365 0.0019122     3 407.86  3.5222   0.01514
##                    
## Year:Sub_region    
## Year            ***
## Sub_region      *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + Sub_region + (1 | Month)
pH_of<-lmer(pH_calculated ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(pH_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: -1888.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.0380 -0.6374  0.0984  0.6899  2.8145 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0011248 0.03354 
##  Residual             0.0005429 0.02330 
## Number of obs: 424, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)   1.740e+01  1.326e+00  4.131e+02  13.122  < 2e-16 ***
## Year         -4.641e-03  6.571e-04  4.131e+02  -7.063 6.94e-12 ***
## Sub_regionUK  1.905e-03  3.589e-03  4.078e+02   0.531    0.596    
## Sub_regionMK  4.307e-03  3.553e-03  4.078e+02   1.212    0.226    
## Sub_regionLK -4.893e-03  3.379e-03  4.079e+02  -1.448    0.148    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.014  0.012  0.623  0.630
   anova(pH_of)
   plot(pH_of)

  qqnorm(resid(pH_of))

  acf(resid(pH_of), main="acf(resid(pH Offshore))")

  pH_of.emmc<-emmeans(pH_of, ~Sub_region)
        pH_of.emmc<-multcomp::cld(pH_of.emmc)
        pH_of.emmc<-pH_of.emmc[order(pH_of.emmc$Sub_region),]
  pH_of.emmc
 #write.csv(pH_of.emmc, "FLK_results/Model_7_LTpH_POST.csv")
# Predict values  
  Of_pH_Pred <- predict(pH_of, newdata=Of_Newdata, 
                        re.form=NA, level=0, asList = FALSE)
  Of_pH_Pred <-cbind(Of_Newdata, Of_pH_Pred)
  Of_pH_Pred$Date<-as.Date(as.character(Of_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_of)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Of_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.offshore, 
                               aes(y=pH_calculated, x=Date, 
                                   #fill = Sub_region), 
                                  colour = Sub_region),  
                               alpha=0.5, size=0.5, shape=24)+
      geom_line(data=Of_pH_Pred, aes(y = Of_pH_Pred, x=Date,  colour = Sub_region),
                                linetype=1, size=1) +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Of_pH_Modeled

Oceanic

hist(Trends.ocean$pH_calculated)

shapiro.test(Trends.ocean$pH_calculated)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$pH_calculated
## W = 0.94851, p-value = 1.265e-05
pH_oc_0<-lmer(pH_calculated ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(pH_oc_0)    
  anova(pH_oc_0)
  ranova(pH_oc_0)
  step(pH_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar logLik     AIC    LRT Df Pr(>Chisq)    
## <none>                     9 340.84 -663.69                         
## (1 | SiteID)          1    8 340.84 -665.69  0.000  1          1    
## (1 | Month)           0    7 306.65 -599.30 68.385  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated    Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)
## Year:Sub_region          1 0.0000317 0.0000158     2 143.50  0.0320    0.9686
## Sub_region               2 0.0009016 0.0004508     2 145.38  0.9225    0.3998
## Year                     0 0.0132501 0.0132501     1 154.48 27.1193 6.021e-07
##                    
## Year:Sub_region    
## Sub_region         
## Year            ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## pH_calculated ~ Year + (1 | Month)
pH_oc<-lmer(pH_calculated ~ Year + (1 | Month),
               data=Trends.ocean)
  summary(pH_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: pH_calculated ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: -719.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6473 -0.6723  0.1239  0.6369  2.4346 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Month    (Intercept) 0.0005838 0.02416 
##  Residual             0.0004886 0.02210 
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  1.837e+01  1.984e+00  1.545e+02   9.257  < 2e-16 ***
## Year        -5.120e-03  9.832e-04  1.545e+02  -5.208 6.02e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  anova(pH_oc) 
  plot(pH_oc)

  qqnorm(resid(pH_oc))

  acf(resid(pH_oc), main="acf(resid(pH ocean))")

  pH_oc.emmc<-emmeans(pH_oc, ~Year)
        pH_oc.emmc<-multcomp::cld(pH_oc.emmc)
        #pH_oc.emmc<-pH_oc.emmc[order(pH_oc.emmc$Sub_region),]
  pH_oc.emmc
# Predict values  
  Oc_pH_Pred <- predict(pH_oc, newdata=Oc_Newdata,
                        re.form=NA, level=0, asList = FALSE)
  Oc_pH_Pred <-cbind(Oc_Newdata, Oc_pH_Pred)
  Oc_pH_Pred$Date<-as.Date(as.character(Oc_pH_Pred$Year), format = "%Y")

# Model summary for slope labels 
  slope<-round(
      summary(pH_oc)$coefficients["Year", "Estimate"], digits = 3)
  #ys <- max(Trends.inshore$pH_calculated, na.rm =T)
  ys <- max(Trends.offshore$pH_calculated, na.rm =T)+0.08
  plot_label <- sprintf("\"\" ~ pH == %0.3f", slope)
  plot_label2 <- expression("Year^-1")  
  
# Plot raw data point and fitted model 
  Oc_pH_Modeled<-Long_plot2+ #facet_grid(~Zone)+
     scale_y_continuous(name=(expression(pH[calculated])),
                      limits=c(7.88, 8.2),
                      # limits=c(7.80, 8.28),
                       breaks = seq(0, 10, 0.1),  
                       expand = c(0, 0.01)) +
    
      geom_point(data=Trends.ocean, 
                               aes(y=pH_calculated, x=Date, #fill = Sub_region), 
                                  colour = Sub_region),  
                                alpha=0.5, size=0.5, shape=25)+
      geom_line(data=Oc_pH_Pred, aes(y = Oc_pH_Pred, x=Date),
                                linetype=1, size=1, colour = "black") +
      annotate(geom="text", x = as.Date(xs), y = ys, parse=TRUE,
           label =paste0(as.character(plot_label, plot_label2, sep = " ")),
           size=4)
  Oc_pH_Modeled

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.pH_in_0 <- data.frame (anova(pH_in_0))
    av.pH_mc_0 <- data.frame (anova(pH_mc_0) )
    av.pH_of_0 <- data.frame (anova(pH_of_0))
    av.pH_oc_0 <- data.frame (anova(pH_oc_0))
    
    # Putting all into one dataframe/table
    anova_pH <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                         rbind(av.pH_in_0, av.pH_mc_0,
                         av.pH_of_0, av.pH_oc_0))) 
    colnames(anova_pH) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_pH) <- NULL
  
  # create HTML table using kableExtra
  anova_pH %>% kable("html", digits=2) %>% 
  kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
pH inshore
Year 0.00 0.00 1 352.91 0.31 0.58
Sub_region 0.01 0.00 3 347.54 0.97 0.40
Year:Sub_region 0.01 0.00 3 347.54 0.97 0.41
pH mid-channel
Year 0.01 0.01 1 329.18 5.72 0.02
Sub_region 0.00 0.00 3 323.55 1.21 0.31
Year:Sub_region 0.00 0.00 3 323.56 1.20 0.31
pH offshore
Year 0.03 0.03 1 409.83 52.89 0.00
Sub_region 0.00 0.00 3 404.84 1.60 0.19
Year:Sub_region 0.00 0.00 3 404.84 1.60 0.19
pH ocean
Year 0.01 0.01 1 150.06 23.63 0.00
Sub_region 0.00 0.00 2 143.49 0.03 0.97
Year:Sub_region 0.00 0.00 2 143.49 0.03 0.97
# R-ANOVAs    
    rav.pH_in_0 <- data.frame (ranova(pH_in_0))
    rav.pH_mc_0 <- data.frame (ranova(pH_mc_0) )
    rav.pH_of_0 <- data.frame (ranova(pH_of_0))
    rav.pH_oc_0 <- data.frame (ranova(pH_oc_0))
    
    # Putting all into one dataframe/table
    ranova_pH <- data.frame(cbind
                    (c("<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)",
                       "<none>", "(1 | Month)", "(1 | SiteID)"), 
                      rbind(rav.pH_in_0, rav.pH_mc_0,
                            rav.pH_of_0, rav.pH_oc_0))) 
    colnames(ranova_pH) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_pH) <- NULL
    
    # create HTML table using kableExtra
    ranova_pH %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "pH inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "pH mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "pH offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "pH ocean", 10, 12)  
npar logLik AIC LRT DF Pr(>Chi Sq)
pH inshore
<none> 11 518.84 -1015.68
(1 | Month) 10 343.63 -667.26 350.42 1 0.00
(1 | SiteID) 10 516.35 -1012.71 4.97 1 0.03
pH mid-channel
<none> 11 621.59 -1221.18
(1 | Month) 10 484.04 -948.08 275.10 1 0.00
(1 | SiteID) 10 621.36 -1222.72 0.46 1 0.50
pH offshore
<none> 11 929.90 -1837.79
(1 | Month) 10 762.18 -1504.35 335.44 1 0.00
(1 | SiteID) 10 929.90 -1839.79 0.00 1 1.00
pH ocean
<none> 9 340.84 -663.69
(1 | Month) 8 306.65 -597.30 68.39 1 0.00
(1 | SiteID) 8 340.84 -665.69 0.00 1 1.00
pH_models_0<-list("Inshore" = pH_in_0, 
                   "Mid channel" = pH_mc_0, 
                   "Offshore" = pH_of_0, 
                   "Ocean" = pH_oc_0)
modelsummary(pH_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (all factors)',
             coef_map=factor_order)
pH model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year −0.004 −0.004+ −0.006*** −0.005*
(0.003) (0.002) (0.001) (0.002)
Intercept 15.192* 16.018*** 20.093*** 17.934***
(6.182) (4.180) (2.820) (4.123)
Upper Keys −3.229 −0.282 −2.967
(7.992) (5.849) (3.554)
Middle Keys −5.943 −2.258 −0.158 0.921
(7.747) (5.189) (3.522) (4.822)
Lower Keys −12.466 −8.421 −5.795+ 0.039
(7.794) (5.235) (3.356) (4.856)
Num.Obs. 373 348 424 161
R2 Marg. 0.036 0.030 0.167 0.191
R2 Cond. 0.706 0.657
AIC −1015.7 −1221.2 −1837.8 −663.7
BIC −972.5 −1178.8 −1793.2 −636.0
ICC 0.7 0.6
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")

Factors removed models

pH_models<-list("Inshore" = pH_in, 
                   "Mid channel" = pH_mc, 
                   "Offshore" = pH_of, 
                   "Ocean" = pH_oc)
modelsummary(pH_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'pH model outputs (factors dropped)',
             coef_map=factor_order)
pH model outputs (factors dropped)
Inshore Mid channel Offshore Ocean
Year −0.002* −0.005*** −0.005***
(0.001) (0.001) (0.001)
Intercept 8.027*** 12.771*** 17.400*** 18.368***
(0.024) (2.163) (1.326) (1.984)
Upper Keys 0.022+ 0.012+ 0.002
(0.013) (0.006) (0.004)
Middle Keys 0.017 0.008 0.004
(0.013) (0.005) (0.004)
Lower Keys −0.021 −0.010+ −0.005
(0.013) (0.005) (0.003)
Num.Obs. 373 348 424 161
R2 Marg. 0.034 0.027 0.058 0.094
R2 Cond. 0.703 0.652 0.693 0.587
AIC −1060.4 −1256.0 −1874.8 −711.1
BIC −1033.0 −1229.1 −1846.4 −698.8
ICC 0.7 0.6 0.7 0.5
RMSE 0.05 0.03 0.02 0.02
+ p
#modelsummary(pH_models, estimate = "p.value")
Trends_pH<-ggarrange(In_pH_Modeled+ theme(axis.title.x=element_blank(),
                                 axis.text.x=element_blank(),
                                 legend.position = "none"),
                  Mc_pH_Modeled + theme(legend.position = "none",
                                 axis.text.x=element_blank(),
                                  axis.title.y=element_blank()),
                                
                  Of_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                                
                  Oc_pH_Modeled + theme(legend.position = "none",
                                        axis.text.x=element_blank(),
                                        axis.title.y=element_blank()),
                  
          labels = c("B"),
          ncol = 4, nrow = 1, widths =c(1.1, 1, 1, 1))
Trends_pH

TA-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$TA_umol_kg
## W = 0.81138, p-value < 2.2e-16

Inshore

# Inshore TA
hist(Trends.inshore$TA_umol_kg)

shapiro.test(Trends.inshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$TA_umol_kg
## W = 0.97131, p-value = 9.403e-07
TA_in_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.inshore)
  #summary(TA_in_0)    
  anova(TA_in_0)
  ranova(TA_in_0)
  step(TA_in_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2111.8 4245.5                          
## (1 | SiteID)          1   10 -2112.4 4244.9   1.315  1     0.2515    
## (1 | Month)           0    9 -2188.0 4394.0 151.123  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)    
## Year:Sub_region          1  23921    7974     3 356.06  1.6785 0.17127    
## Year                     2  15420   15420     1 369.35  3.2277 0.07322 .  
## Sub_region               0 500931  166977     3 359.97 34.7828 < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Sub_region + (1 | Month)
TA_in<-lmer(TA_umol_kg ~ Sub_region + (1 | Month), 
            data=Trends.inshore)
  summary(TA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4250.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5060 -0.5701  0.0374  0.6109  3.2811 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 3771     61.41   
##  Residual             4801     69.29   
## Number of obs: 375, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2377.924     19.544   14.611 121.672  < 2e-16 ***
## Sub_regionUK    1.656     10.851  359.916   0.153  0.87876    
## Sub_regionMK  -31.623     10.639  359.921  -2.973  0.00315 ** 
## Sub_regionLK  -87.269     10.552  359.997  -8.270 2.62e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.311              
## Sub_reginMK -0.319  0.571       
## Sub_reginLK -0.322  0.574  0.589
  plot(TA_in)

  qqnorm(resid(TA_in))

  acf(resid(TA_in), main="acf(resid(TA Inshore))") 

  TA_in.emmc<-emmeans(TA_in, ~Sub_region)
        TA_in.emmc<-multcomp::cld(TA_in.emmc)
        TA_in.emmc<-TA_in.emmc[order(TA_in.emmc$Sub_region),]
  TA_in.emmc

Mid channel

hist(Trends.midchanel$TA_umol_kg)

shapiro.test(Trends.midchanel$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$TA_umol_kg
## W = 0.8639, p-value < 2.2e-16
TA_mc_0<-lmer(TA_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
            data=Trends.midchanel)
  #summary(TA_mc_0)    
  anova(TA_mc_0)
  ranova(TA_mc_0)
  step(TA_mc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1817.1 3656.2                         
## (1 | Month)           0   10 -1849.4 3718.9 64.655  1  8.922e-16 ***
## (1 | SiteID)          0   10 -1818.7 3657.4  3.158  1    0.07558 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6340.2  2113.4     3 325.60  1.0805 0.35744  
## Year                     2  3283.1  3283.1     1 337.74  1.6769 0.19622  
## Sub_region               3 26280.6  8760.2     3   6.22  4.4754 0.05406 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ (1 | Month) + (1 | SiteID)
TA_mc<-lmer(TA_umol_kg ~ (1 | Month) + (1|SiteID), 
            data = Trends.midchanel)
  summary(TA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3682.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0700 -0.3976  0.1134  0.5259  3.4567 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  696.8   26.40   
##  SiteID   (Intercept)  232.8   15.26   
##  Residual             1957.7   44.25   
## Number of obs: 350, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept) 2365.447      9.358   16.222   252.8   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_mc)

  qqnorm(resid(TA_mc))

  acf(resid(TA_mc), main="acf(resid(TA Mid Channel))") 

Offshore

hist(Trends.offshore$TA_umol_kg)

shapiro.test(Trends.offshore$TA_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$TA_umol_kg
## W = 0.88506, p-value < 2.2e-16
TA_of_0<-lmer(TA_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(TA_of_0)    
  anova(TA_of_0)
  ranova(TA_of_0)
  step(TA_of_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1856.1 3734.2                         
## (1 | SiteID)          1   10 -1856.1 3732.2  0.000  1          1    
## (1 | Month)           0    9 -1878.5 3775.1 44.909  1  2.064e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  154.6   51.53     3 408.87  0.1454 0.93261  
## Year                     0 1806.8 1806.84     1 400.97  5.1298 0.02405 *
## Sub_region               0 2996.0  998.68     3 412.25  2.8353 0.03792 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + Sub_region + (1 | Month)
TA_of<-lmer(TA_umol_kg ~ Year + Sub_region + (1 | Month), 
            data =Trends.offshore)
  summary(TA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3719
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.5140 -0.3773  0.1021  0.5952  3.4228 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  58.97    7.679  
##  Residual             352.23   18.768  
## Number of obs: 427, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)  
## (Intercept)    41.5577  1032.8949  400.9112   0.040   0.9679  
## Year            1.1592     0.5118  400.9684   2.265   0.0241 *
## Sub_regionUK   -0.5389     2.8906  411.7814  -0.186   0.8522  
## Sub_regionMK   -6.2459     2.8620  411.7525  -2.182   0.0296 *
## Sub_regionLK   -5.2199     2.7133  412.6123  -1.924   0.0551 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.005  0.003  0.591       
## Sub_reginLK -0.007  0.006  0.625  0.632
  plot(TA_of)

  qqnorm(resid(TA_of))

  acf(resid(TA_of), main="acf(resid(TA Offshore))") 

  TA_of.emmc<-emmeans(TA_of, ~Sub_region)
        TA_of.emmc<-multcomp::cld(TA_of.emmc)
        TA_of.emmc<-TA_of.emmc[order(TA_of.emmc$Sub_region),]
  TA_of.emmc

Oceanic

hist(Trends.ocean$TA_umol_kg)

shapiro.test(Trends.ocean$TA_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$TA_umol_kg
## W = 0.9887, p-value = 0.2158
TA_oc_0<-lmer(TA_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(TA_oc_0)    
  anova(TA_oc_0)
  ranova(TA_oc_0)
  step(TA_oc_0)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                     9 -620.60 1259.2                         
## (1 | SiteID)          1    8 -620.60 1257.2  0.000  1   1.000000    
## (1 | Month)           0    7 -626.34 1266.7 11.479  1   0.000704 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   36.60   18.30     2 147.47  0.1497 0.861116   
## Sub_region               2  240.91  120.45     2 149.14  0.9962 0.371707   
## Year                     0 1185.68 1185.68     1 157.86  9.7917 0.002088 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## TA_umol_kg ~ Year + (1 | Month)
TA_oc<-lmer(TA_umol_kg ~ (1 | Month), 
            data = Trends.ocean)
  summary(TA_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: TA_umol_kg ~ (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1263.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7341 -0.5888  0.1002  0.6518  2.8046 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  21.01    4.584  
##  Residual             128.16   11.321  
## Number of obs: 163, groups:  Month, 12
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept) 2381.578      1.612   11.140    1478   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  plot(TA_oc)

  qqnorm(resid(TA_oc))

  acf(resid(TA_oc), main="acf(resid(TA_Ocean))")

  # TA_oc.emmc<-emmeans(TA_oc, ~Sub_region)
  #       TA_oc.emmc<-multcomp::cld(TA_oc.emmc)
  #       TA_oc.emmc<-TA_oc.emmc[order(TA_oc.emmc$Sub_region),]
  # TA_oc.emmc

Models summary

Complete models

# ANOVAs
    # Convert ANOVA results into dataframes allows for easier name manipulation
    av.TA_in_0 <- data.frame (anova(TA_in_0))
    av.TA_mc_0 <- data.frame (anova(TA_mc_0) )
    av.TA_of_0 <- data.frame (anova(TA_of_0))
    av.TA_oc_0 <- data.frame (anova(TA_oc_0))
    
    # Putting all into one dataframe/table
    anova_TA_0 <- data.frame(cbind
                    (c("Year", "Sub_region", "Year:Sub_region", 
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region",
                       "Year", "Sub_region", "Year:Sub_region"), 
                                      rbind(av.TA_in_0, av.TA_mc_0,
                                            av.TA_of_0, av.TA_oc_0))) 
    colnames(anova_TA_0) <- c("", "Sum Sq", "Mean Sq", "N Df" , "D Df",
                                     "F value", "Pr(>F)")
    row.names(anova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    anova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)  
Sum Sq Mean Sq N Df D Df F value Pr(>F)
TA inshore
Year 12144.36 12144.36 1 360.75 2.59 0.11
Sub_region 24071.88 8023.96 3 350.04 1.71 0.16
Year:Sub_region 24057.93 8019.31 3 350.04 1.71 0.16
TA mid-channel
Year 2234.06 2234.06 1 335.44 1.14 0.29
Sub_region 6343.28 2114.43 3 325.60 1.08 0.36
Year:Sub_region 6340.22 2113.41 3 325.60 1.08 0.36
TA offshore
Year 1575.10 1575.10 1 401.06 4.44 0.04
Sub_region 155.57 51.86 3 408.83 0.15 0.93
Year:Sub_region 154.60 51.53 3 408.83 0.15 0.93
TA ocean
Year 1082.81 1082.81 1 155.65 8.86 0.00
Sub_region 36.41 18.21 2 147.46 0.15 0.86
Year:Sub_region 36.60 18.30 2 147.46 0.15 0.86
# R-ANOVAs    
    rav.TA_in_0 <- data.frame (ranova(TA_in_0))
    rav.TA_mc_0 <- data.frame (ranova(TA_mc_0) )
    rav.TA_of_0 <- data.frame (ranova(TA_of_0))
    rav.TA_oc_0 <- data.frame (ranova(TA_oc_0))
    
# Putting all into one dataframe/table
  ranova_TA_0 <- data.frame(cbind
                  (c("<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)",
                     "<none>", "(1 | Month)", "(1 | SiteID)"), 
               rbind(rav.TA_in_0, rav.TA_mc_0,
                            rav.TA_of_0, rav.TA_oc_0))) 
    colnames(ranova_TA_0) <- c("", "npar", "logLik", "AIC" , "LRT",
                                     "DF", "Pr(>Chi Sq)")
    row.names(ranova_TA_0) <- NULL
    
    # create HTML table using kableExtra
    ranova_TA_0 %>% kable("html", digits=2) %>% 
      kable_styling(bootstrap_options = "striped", full_width = F) %>% 
      pack_rows(., "TA inshore", 1, 3) %>% # groups rows with label
      pack_rows(., "TA mid-channel", 4, 6)  %>% # groups rows with label
      pack_rows(., "TA offshore", 7, 9) %>% # groups rows with label
      pack_rows(., "TA ocean", 10, 12)
npar logLik AIC LRT DF Pr(>Chi Sq)
TA inshore
<none> 11 -2111.77 4245.54
(1 | Month) 10 -2187.98 4395.97 152.43 1 0.00
(1 | SiteID) 10 -2112.43 4244.86 1.32 1 0.25
TA mid-channel
<none> 11 -1817.11 3656.22
(1 | Month) 10 -1849.44 3718.87 64.66 1 0.00
(1 | SiteID) 10 -1818.69 3657.37 3.16 1 0.08
TA offshore
<none> 11 -1856.08 3734.16
(1 | Month) 10 -1878.53 3777.07 44.91 1 0.00
(1 | SiteID) 10 -1856.08 3732.16 0.00 1 1.00
TA ocean
<none> 9 -620.60 1259.19
(1 | Month) 8 -626.34 1268.67 11.48 1 0.00
(1 | SiteID) 8 -620.60 1257.19 0.00 1 1.00
TA_models_0<-list("Inshore" = TA_in_0, 
                   "Mid channel" = TA_mc_0, 
                   "Offshore" = TA_of_0, 
                   "Ocean" = TA_oc_0)
modelsummary(TA_models_0, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (all factors)',
             coef_map=factor_order)
TA model outputs (all factors)
Inshore Mid channel Offshore Ocean
Year 1.046 0.873 0.560 1.525
(4.079) (2.661) (1.124) (1.002)
Intercept 266.964 616.763 1249.936 −695.347
(8230.631) (5370.342) (2267.304) (2021.206)
Upper Keys 555.392 2035.391 −1299.384
(10657.499) (7552.355) (2877.320)
Middle Keys −17995.336+ −8041.978 −1874.329 −355.634
(10334.207) (6699.927) (2851.984) (2388.676)
Lower Keys −1234.489 1139.413 −1257.505 674.419
(10357.074) (6732.364) (2707.705) (2401.637)
Num.Obs. 375 350 427 163
R2 Marg. 0.150 0.073 0.035 0.080
R2 Cond. 0.526 0.325
AIC 4245.5 3656.2 3734.2 1259.2
BIC 4288.7 3698.7 3778.8 1287.0
ICC 0.4 0.3
RMSE 66.44 42.86 18.44 10.59
+ p
#modelsummary(TA_models, estimate = "p.value")

Factors removed models

TA_models<-list("Inshore" = TA_in, 
                   "Mid channel" = TA_mc, 
                   "Offshore" = TA_of, 
                   "Ocean" = TA_oc)
modelsummary(TA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'TA model outputs (dropped facators)',
             coef_map=factor_order)
TA model outputs (dropped facators)
Inshore Mid channel Offshore Ocean
Year 1.159*
(0.512)
Intercept 2377.924*** 2365.447*** 41.558 2381.578***
(19.544) (9.358) (1032.895) (1.612)
Upper Keys 1.656 −0.539
(10.851) (2.891)
Middle Keys −31.623** −6.246*
(10.639) (2.862)
Lower Keys −87.269*** −5.220+
(10.552) (2.713)
Num.Obs. 375 350 427 163
R2 Marg. 0.136 0.000 0.030 0.000
R2 Cond. 0.516 0.322 0.169 0.141
AIC 4262.9 3690.6 3733.0 1269.7
BIC 4286.4 3706.0 3761.4 1278.9
ICC 0.4 0.3 0.1 0.1
RMSE 67.93 43.08 18.45 11.03
+ p
#modelsummary(TA_models, estimate = "p.value")

DIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.data$DIC_umol_kg
## W = 0.90821, p-value < 2.2e-16

Inshore

hist(Trends.inshore$DIC_umol_kg)

shapiro.test(Trends.inshore$DIC_umol_kg)# Normality NOT rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$DIC_umol_kg
## W = 0.99705, p-value = 0.7394
# Inshore DIC
DIC_in<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(DIC_in)    
  anova(DIC_in)
  ranova(DIC_in)
  step(DIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2114.4 4250.7                          
## (1 | Month)           0   10 -2240.7 4501.3 252.580  1     <2e-16 ***
## (1 | SiteID)          0   10 -2116.5 4253.0   4.252  1     0.0392 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  25312    8437     3 347.80  1.7086 0.16492  
## Year                     0  31161   31161     1 358.73  6.2722 0.01271 *
## Sub_region               0  95613   31871     3   7.24  6.4151 0.01913 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
DIC_in<-lmer(DIC_umol_kg ~ Year + Sub_region +
               (1|Month) + (1|SiteID), data=Trends.inshore)
  summary(DIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4248.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4161 -0.6586  0.0303  0.6553  2.7863 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6626.4   81.40   
##  SiteID   (Intercept)  219.1   14.80   
##  Residual             4968.1   70.48   
## Number of obs: 373, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept)  -8737.835   4311.479   358.756  -2.027  0.04344 * 
## Year             5.350      2.136   358.733   2.504  0.01271 * 
## Sub_regionUK   -16.641     17.467     7.250  -0.953  0.37140   
## Sub_regionMK   -44.133     17.314     7.009  -2.549  0.03812 * 
## Sub_regionLK   -68.049     17.283     6.958  -3.937  0.00569 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.035  0.033              
## Sub_reginMK -0.010  0.008  0.588       
## Sub_reginLK -0.018  0.016  0.589  0.595
  plot(DIC_in)

  qqnorm(resid(DIC_in))

  acf(resid(DIC_in), main="acf(resid(DIC Inshore))") 

  DIC_in.emmc<-emmeans(DIC_in, ~Sub_region+Year)
         DIC_in.emmc<-multcomp::cld(DIC_in.emmc)
         DIC_in.emmc<-DIC_in.emmc[order(DIC_in.emmc$Sub_region),]
  DIC_in.emmc

Mid channel

hist(Trends.midchanel$DIC_umol_kg)

shapiro.test(Trends.midchanel$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$DIC_umol_kg
## W = 0.94836, p-value = 1.109e-09
DIC_mc<-lmer(DIC_umol_kg~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(DIC_mc)    
  anova(DIC_mc)
  ranova(DIC_mc)
  step(DIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -1833.5 3689.0                          
## (1 | SiteID)          1   10 -1834.1 3688.1   1.085  1     0.2975    
## (1 | Month)           0    9 -1891.7 3801.3 115.233  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1   8033  2677.6     3 329.04  1.1682 0.321879   
## Year                     0  11372 11371.7     1 342.72  4.9528 0.026698 * 
## Sub_region               0  34301 11433.8     3 332.14  4.9799 0.002156 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month)
DIC_mc<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month), 
             data = Trends.midchanel)
  summary(DIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3684.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.2953 -0.4748  0.0154  0.5750  3.7927 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1395     37.34   
##  Residual             2296     47.92   
## Number of obs: 348, groups:  Month, 12
## 
## Fixed effects:
##               Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  -4589.568   2984.771   342.723  -1.538 0.125054    
## Year             3.291      1.479   342.719   2.225 0.026698 *  
## Sub_regionUK    -7.413      8.314   332.145  -0.892 0.373229    
## Sub_regionMK   -21.935      7.358   332.068  -2.981 0.003083 ** 
## Sub_regionLK   -24.601      7.343   332.174  -3.350 0.000901 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.012  0.011              
## Sub_reginMK -0.002  0.000  0.530       
## Sub_reginLK -0.018  0.016  0.532  0.601
  plot(DIC_mc)

  qqnorm(resid(DIC_mc))

  acf(resid(DIC_mc), main="acf(resid(DIC Mid Channel))") 

  DIC_mc.emmc<-emmeans(DIC_mc, ~Sub_region+Year)
         DIC_mc.emmc<-multcomp::cld(DIC_mc.emmc)
         DIC_mc.emmc<-DIC_mc.emmc[order(DIC_mc.emmc$Sub_region),]
  DIC_mc.emmc

Offshore

hist(Trends.offshore$DIC_umol_kg)

shapiro.test(Trends.offshore$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$DIC_umol_kg
## W = 0.95542, p-value = 4.729e-10
DIC_of<-lmer(DIC_umol_kg~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(DIC_of)    
  anova(DIC_of)
  ranova(DIC_of)
  step(DIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC   LRT Df Pr(>Chisq)    
## <none>                    11 -1932.8 3887.7                        
## (1 | SiteID)          1   10 -1932.8 3885.7  0.00  1          1    
## (1 | Month)           0    9 -1963.0 3944.0 60.28  1  8.226e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   806.3   268.8     3 407.55  0.5178   0.67026    
## Year                     0 23228.6 23228.6     1 411.35 44.9099 6.813e-11 ***
## Sub_region               0  4742.8  1580.9     3 410.76  3.0565   0.02825 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + Sub_region + (1 | Month)
DIC_of<-lmer(DIC_umol_kg ~ Year + Sub_region + (1 | Month),
             data =Trends.offshore)
  summary(DIC_of)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3874.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.9981 -0.5363  0.1094  0.5639  2.6471 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 116.7    10.80   
##  Residual             517.2    22.74   
## Number of obs: 426, groups:  Month, 12
## 
## Fixed effects:
##                Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)  -6415.8631  1263.6062   411.3193  -5.077 5.81e-07 ***
## Year             4.1960     0.6261   411.3550   6.701 6.81e-11 ***
## Sub_regionUK    -2.7095     3.5029   410.5267  -0.774   0.4397    
## Sub_regionMK    -8.5696     3.4683   410.5117  -2.471   0.0139 *  
## Sub_regionLK    -0.6895     3.2882   410.9233  -0.210   0.8340    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.004  0.002              
## Sub_reginMK -0.004  0.003  0.591       
## Sub_reginLK -0.013  0.011  0.625  0.632
  plot(DIC_of)

  qqnorm(resid(DIC_of))

  acf(resid(DIC_of), main="acf(resid(DIC Offshore))") 

  DIC_of.emmc<-emmeans(DIC_of, ~Sub_region+Year)
         DIC_of.emmc<-multcomp::cld(DIC_of.emmc)
         DIC_of.emmc<-DIC_of.emmc[order(DIC_of.emmc$Sub_region),]
  DIC_of.emmc

Oceanic

hist(Trends.ocean$DIC_umol_kg)

shapiro.test(Trends.ocean$DIC_umol_kg)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.ocean$DIC_umol_kg
## W = 0.97946, p-value = 0.01698
DIC_oc<-lmer(DIC_umol_kg ~ Year * Sub_region + 
               (1 | Month)+ (1|SiteID),
               data=Trends.ocean)
  #summary(DIC_oc)    
  anova(DIC_oc)
  ranova(DIC_oc)
  step(DIC_oc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)  
## <none>                     9 -684.21 1386.4                       
## (1 | SiteID)          1    8 -684.21 1384.4 0.0000  1    1.00000  
## (1 | Month)           0    7 -687.08 1388.2 5.7341  1    0.01664 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   119.2    59.6     2 146.26  0.1898    0.8273    
## Sub_region               2   158.1    79.0     2 148.05  0.2546    0.7756    
## Year                     0 13827.2 13827.2     1 151.57 45.0044 3.671e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## DIC_umol_kg ~ Year + (1 | Month)
DIC_oc<-lmer(DIC_umol_kg ~ Year+ (1 | Month), data = Trends.ocean)
  summary(DIC_oc)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: DIC_umol_kg ~ Year + (1 | Month)
##    Data: Trends.ocean
## 
## REML criterion at convergence: 1383.4
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.54294 -0.63178 -0.03277  0.54011  2.77577 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  35.49    5.958  
##  Residual             307.24   17.528  
## Number of obs: 161, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept) -7873.046   1479.171   151.554  -5.323 3.62e-07 ***
## Year            4.917      0.733   151.572   6.709 3.67e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##      (Intr)
## Year -1.000
  plot(DIC_oc)

  qqnorm(resid(DIC_oc))

  acf(resid(DIC_oc), main="acf(resid(DIC open))")

  DIC_oc.emmc<-emmeans(DIC_oc, ~Year)
         DIC_oc.emmc<-multcomp::cld(DIC_oc.emmc)
         #DIC_oc.emmc<-DIC_oc.emmc[order(DIC_oc.emmc$Sub_region),]
  DIC_oc.emmc

Models summary

DIC_models<-list("Inshore" = DIC_in, 
                   "Mid channel" = DIC_mc, 
                   "Offshore" = DIC_of, 
                   "Ocean" = DIC_oc)
modelsummary(DIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'DIC model outputs',
             coef_map=factor_order)
DIC model outputs
Inshore Mid channel Offshore Ocean
Year 5.350* 3.291* 4.196*** 4.917***
(2.136) (1.479) (0.626) (0.733)
Intercept −8737.835* −4589.568 −6415.863*** −7873.046***
(4311.479) (2984.771) (1263.606) (1479.171)
Upper Keys −16.641 −7.413 −2.710
(17.467) (8.314) (3.503)
Middle Keys −44.133* −21.935** −8.570*
(17.314) (7.358) (3.468)
Lower Keys −68.049*** −24.601*** −0.690
(17.283) (7.343) (3.288)
Num.Obs. 373 348 426 161
R2 Marg. 0.061 0.038 0.116 0.230
R2 Cond. 0.605 0.401 0.279 0.309
AIC 4264.5 3698.2 3888.8 1391.4
BIC 4295.8 3725.2 3917.2 1403.7
ICC 0.6 0.4 0.2 0.1
RMSE 68.58 46.85 22.35 17.06
+ p
#modelsummary(DIC_models, estimate = "p.value")

dTA-All

Long_plot2<- ggplot(Reef.Trends.data) +
        MyTheme +  
        #scale_shape_manual(values=c(24, 25, 21))+
        #guides(fill=guide_legend(override.aes=list(shape=21)))+
        theme(axis.title.x = element_blank())

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dTA_MY
## W = 0.81068, p-value < 2.2e-16

Inshore

# Inshore dTA
hist(Trends.inshore$dTA_MY)

shapiro.test(Trends.inshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dTA_MY
## W = 0.96647, p-value = 1.722e-07
dTA_in<-lmer(dTA_MY ~ Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.inshore)
  #summary(dTA_in)    
  anova(dTA_in)
  ranova(dTA_in)
  step(dTA_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2070.3 4162.7                          
## (1 | SiteID)          1   10 -2071.1 4162.3   1.563  1     0.2112    
## (1 | Month)           0    9 -2149.7 4317.4 157.089  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)    
## Year:Sub_region          1  23417    7806     3 349.98  1.7157 0.1634    
## Year                     2   4185    4185     1 362.89  0.9143 0.3396    
## Sub_region               0 503930  167977     3 353.92 36.7310 <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month)
dTA_in<-lmer(dTA_MY ~ Sub_region + (1 | Month),
             data=Trends.inshore)
  summary(dTA_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4165.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5706 -0.5791  0.0397  0.5825  3.2500 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 3901     62.46   
##  Residual             4573     67.63   
## Number of obs: 369, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)    -3.053     19.782  14.400  -0.154   0.8795    
## Sub_regionUK    1.901     10.751 353.895   0.177   0.8597    
## Sub_regionMK  -32.076     10.489 353.896  -3.058   0.0024 ** 
## Sub_regionLK  -87.830     10.382 353.949  -8.460 7.14e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.304              
## Sub_reginMK -0.312  0.573       
## Sub_reginLK -0.316  0.578  0.595
  plot(dTA_in)

  qqnorm(resid(dTA_in))

  acf(resid(dTA_in), main="acf(resid(dTA Inshore))")

  dTA_in.emmc<-emmeans(dTA_in, ~Sub_region)
         dTA_in.emmc<-multcomp::cld(dTA_in.emmc)
         dTA_in.emmc<-dTA_in.emmc[order(dTA_in.emmc$Sub_region),]
  dTA_in.emmc

Mid channel

hist(Trends.midchanel$dTA_MY)

shapiro.test(Trends.midchanel$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dTA_MY
## W = 0.83138, p-value < 2.2e-16
dTA_mc<-lmer(dTA_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID),
             data=Trends.midchanel)
  #summary(dTA_mc)    
  anova(dTA_mc)
  ranova(dTA_mc)
  step(dTA_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1785.4 3592.9                         
## (1 | Month)           0   10 -1824.0 3668.1 77.191  1    < 2e-16 ***
## (1 | SiteID)          0   10 -1787.5 3594.9  4.048  1    0.04423 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Year:Sub_region          1  6411.6  2137.2     3 322.19  1.2124 0.30521  
## Year                     2     9.9     9.9     1 336.32  0.0056 0.94029  
## Sub_region               3 24315.0  8105.0     3   6.24  4.6010 0.05089 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ (1 | Month) + (1 | SiteID)
dTA_mc<-lmer(dTA_MY ~ (1 | Month) + (1|SiteID), 
             data = Trends.midchanel)
  summary(dTA_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ (1 | Month) + (1 | SiteID)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3617.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0331 -0.3800  0.1133  0.5555  3.4580 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  767.2   27.70   
##  SiteID   (Intercept)  240.9   15.52   
##  Residual             1761.7   41.97   
## Number of obs: 347, groups:  Month, 12; SiteID, 10
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)
## (Intercept)  -16.062      9.679  16.151   -1.66    0.116
  plot(dTA_mc)

  qqnorm(resid(dTA_mc))

  acf(resid(dTA_mc), main="acf(resid(dTA Mid Channel))") 

Offshore

hist(Trends.offshore$dTA_MY)

shapiro.test(Trends.offshore$dTA_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dTA_MY
## W = 0.81414, p-value < 2.2e-16
dTA_of<-lmer(dTA_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dTA_of)    
  anova(dTA_of)
  ranova(dTA_of)
  step(dTA_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1762.3 3546.5                         
## (1 | SiteID)          1   10 -1762.3 3544.5  0.000  1          1    
## (1 | Month)           0    9 -1784.5 3587.0 44.459  1  2.597e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated  Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
## Year:Sub_region          1  163.74   54.58     3 402.83  0.2192 0.8831  
## Year                     2  382.27  382.27     1 404.60  1.5439 0.2148  
## Sub_region               0 2792.28  930.76     3 407.46  3.7460 0.0112 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dTA_MY ~ Sub_region + (1 | Month)
dTA_of<-lmer(dTA_MY ~ Sub_region + (1 | Month), 
             data =Trends.offshore)
  summary(dTA_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dTA_MY ~ Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3532.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.7134 -0.3128  0.1093  0.5378  3.7524 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  47.53    6.894  
##  Residual             248.47   15.763  
## Number of obs: 422, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)  
## (Intercept)   -1.1008     2.7538  28.9761  -0.400   0.6923  
## Sub_regionUK  -0.2335     2.4524 407.0094  -0.095   0.9242  
## Sub_regionMK  -5.8844     2.4333 407.0245  -2.418   0.0160 *
## Sub_regionLK  -4.9534     2.2996 407.7183  -2.154   0.0318 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.525              
## Sub_reginMK -0.531  0.595       
## Sub_reginLK -0.564  0.630  0.636
  plot(dTA_of)

  qqnorm(resid(dTA_of))

  acf(resid(dTA_of), main="acf(resid(dTA Offshore))") 

  dTA_of.emmc<-emmeans(dTA_of, ~Sub_region)
         dTA_of.emmc<-multcomp::cld(dTA_of.emmc)
         dTA_of.emmc<-dTA_of.emmc[order(dTA_of.emmc$Sub_region),]
  dTA_of.emmc

Models summary

dTA_models<-list("Inshore" = dTA_in, 
                   "Mid channel" = dTA_mc, 
                   "Offshore" = dTA_of)
modelsummary(dTA_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dTA model outputs',
             coef_map=factor_order)
dTA model outputs
Inshore Mid channel Offshore
Intercept −3.053 −16.062+ −1.101
(19.782) (9.679) (2.754)
Upper Keys 1.901 −0.233
(10.751) (2.452)
Middle Keys −32.076** −5.884*
(10.489) (2.433)
Lower Keys −87.830*** −4.953*
(10.382) (2.300)
Num.Obs. 369 347 422
R2 Marg. 0.140 0.000 0.022
R2 Cond. 0.536 0.364 0.179
AIC 4177.9 3625.7 3544.2
BIC 4201.4 3641.1 3568.4
ICC 0.5 0.4 0.2
RMSE 66.28 40.84 15.51
+ p
#modelsummary(dTA_models, estimate = "p.value")

dDIC-All

## 
##  Shapiro-Wilk normality test
## 
## data:  Reef.Trends.data$dDIC_MY
## W = 0.8692, p-value < 2.2e-16

Inshore

# Inshore dDIC
hist(Trends.inshore$dDIC_MY)

shapiro.test(Trends.inshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.inshore$dDIC_MY
## W = 0.99195, p-value = 0.04425
dDIC_in<-lmer(dDIC_MY~Year * Sub_region + (1|Month)+
                                  #(1|Zone)+             
                                  (1|SiteID), 
              data=Trends.inshore)
  #summary(dDIC_in)    
  anova(dDIC_in)
  ranova(dDIC_in)
  step(dDIC_in)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC     LRT Df Pr(>Chisq)    
## <none>                    11 -2063.4 4148.7                          
## (1 | Month)           0   10 -2186.1 4392.3 245.533  1    < 2e-16 ***
## (1 | SiteID)          0   10 -2066.2 4152.3   5.591  1    0.01805 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
## Year:Sub_region          1  25267  8422.5     3 341.81  1.8782 0.1330  
## Year                     2      1     1.3     1 352.47  0.0003 0.9863  
## Sub_region               0  90826 30275.4     3   7.26  6.7192 0.0169 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
dDIC_in<-lmer(dDIC_MY ~ Sub_region + (1 | Month)+ (1 | SiteID),
              data=Trends.inshore)
  summary(dDIC_in)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month) + (1 | SiteID)
##    Data: Trends.inshore
## 
## REML criterion at convergence: 4149.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.4747 -0.6231  0.0291  0.6380  2.9028 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 6077.1   77.96   
##  SiteID   (Intercept)  241.3   15.53   
##  Residual             4505.8   67.13   
## Number of obs: 367, groups:  Month, 12; SiteID, 11
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)    10.259     26.313  16.255   0.390  0.70170   
## Sub_regionUK  -16.022     17.754   7.330  -0.902  0.39551   
## Sub_regionMK  -44.964     17.592   7.073  -2.556  0.03745 * 
## Sub_regionLK  -70.184     17.548   7.002  -3.999  0.00519 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.395              
## Sub_reginMK -0.399  0.590       
## Sub_reginLK -0.400  0.591  0.597
  plot(dDIC_in)

  qqnorm(resid(dDIC_in))

  acf(resid(dDIC_in), main="acf(resid(dDIC Inshore))") 

  dDIC_in.emmc<-emmeans(dDIC_in, ~Sub_region)
         dDIC_in.emmc<-multcomp::cld(dDIC_in.emmc)
         dDIC_in.emmc<-dDIC_in.emmc[order(dDIC_in.emmc$Sub_region),]
  dDIC_in.emmc

Mid channel

hist(Trends.midchanel$dDIC_MY)

shapiro.test(Trends.midchanel$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.midchanel$dDIC_MY
## W = 0.89741, p-value = 1.698e-14
dDIC_mc<-lmer(dDIC_MY~Year * Sub_region + (1|Month) + 
                                  #(1|Zone)+             
                                  (1|SiteID), data=Trends.midchanel)
  #summary(dDIC_mc)    
  anova(dDIC_mc)
  ranova(dDIC_mc)
  step(dDIC_mc)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1780.2 3582.4                         
## (1 | SiteID)          1   10 -1781.4 3582.8   2.36  1     0.1244    
## (1 | Month)           0    9 -1842.3 3702.7 121.87  1     <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Year:Sub_region          1   8833  2944.4     3 326.01  1.6029 0.1885586    
## Year                     2   4982  4981.7     1 339.38  2.6964 0.1015017    
## Sub_region               0  36387 12128.9     3 330.09  6.5221 0.0002686 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Sub_region + (1 | Month)
dDIC_mc<-lmer(dDIC_MY ~ Sub_region + (1 | Month),
              data = Trends.midchanel)
  summary(dDIC_mc) 
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Sub_region + (1 | Month)
##    Data: Trends.midchanel
## 
## REML criterion at convergence: 3584.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.4652 -0.4651  0.0496  0.5297  3.9540 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept) 1185     34.43   
##  Residual             1860     43.12   
## Number of obs: 345, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)     3.351     11.248  15.909   0.298 0.769611    
## Sub_regionUK   -9.260      7.525 330.051  -1.230 0.219398    
## Sub_regionMK  -22.939      6.690 330.028  -3.429 0.000683 ***
## Sub_regionLK  -26.218      6.662 330.093  -3.936 0.000101 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Sb_rUK Sb_rMK
## Sub_reginUK -0.319              
## Sub_reginMK -0.360  0.535       
## Sub_reginLK -0.362  0.538  0.607
  plot(dDIC_mc) 

  qqnorm(resid(dDIC_mc))

  acf(resid(dDIC_mc), main="acf(resid(dDIC Mid Channel))") 

  dDIC_mc.emmc<-emmeans(dDIC_mc, ~Sub_region)
         dDIC_mc.emmc<-multcomp::cld(dDIC_mc.emmc)
         dDIC_mc.emmc<-dDIC_mc.emmc[order(dDIC_mc.emmc$Sub_region),]
  dDIC_mc.emmc

Offshore

hist(Trends.offshore$dDIC_MY)

shapiro.test(Trends.offshore$dDIC_MY)# Normality rejected
## 
##  Shapiro-Wilk normality test
## 
## data:  Trends.offshore$dDIC_MY
## W = 0.78379, p-value < 2.2e-16
dDIC_of<-lmer(dDIC_MY~Year * Sub_region + 
               (1|Month) + (1|SiteID),
               data=Trends.offshore)
  #summary(dDIC_of)    
  anova(dDIC_of)
  ranova(dDIC_of)
  step(dDIC_of)
## Backward reduced random-effect table:
## 
##              Eliminated npar  logLik    AIC    LRT Df Pr(>Chisq)    
## <none>                    11 -1741.1 3504.3                         
## (1 | SiteID)          1   10 -1741.1 3502.3  0.000  1          1    
## (1 | Month)           0    9 -1755.0 3527.9 27.641  1   1.46e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Backward reduced fixed-effect table:
## Degrees of freedom method: Satterthwaite 
## 
##                 Eliminated Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
## Year:Sub_region          1 1001.5  333.84     3 402.26  1.4401 0.230586   
## Year                     0 1594.1 1594.11     1 381.54  6.8540 0.009197 **
## Sub_region               0 3812.6 1270.86     3 405.62  5.4641 0.001087 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Model found:
## dDIC_MY ~ Year + Sub_region + (1 | Month)
dDIC_of<-lmer(dDIC_MY ~ Year+ Sub_region + (1 | Month), 
              data =Trends.offshore)
  summary(dDIC_of)    
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: dDIC_MY ~ Year + Sub_region + (1 | Month)
##    Data: Trends.offshore
## 
## REML criterion at convergence: 3491.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -6.4443 -0.3349  0.1161  0.5360  3.8120 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Month    (Intercept)  30.53    5.525  
##  Residual             232.58   15.251  
## Number of obs: 421, groups:  Month, 12
## 
## Fixed effects:
##              Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  2188.848    835.522  381.460   2.620 0.009151 ** 
## Year           -1.084      0.414  381.538  -2.618 0.009197 ** 
## Sub_regionUK   -2.824      2.373  405.232  -1.190 0.234631    
## Sub_regionMK   -8.251      2.354  405.265  -3.505 0.000508 ***
## Sub_regionLK   -1.524      2.225  405.813  -0.685 0.493829    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Year   Sb_rUK Sb_rMK
## Year        -1.000                     
## Sub_reginUK -0.005  0.003              
## Sub_reginMK -0.005  0.003  0.595       
## Sub_reginLK -0.014  0.012  0.630  0.636
  plot(dDIC_of)

  qqnorm(resid(dDIC_of))

  acf(resid(dDIC_of), main="acf(resid(dDIC Offshore))") 

  dDIC_of.emmc<-emmeans(dDIC_of, ~Sub_region+Year)
         dDIC_of.emmc<-multcomp::cld(dDIC_of.emmc)
         dDIC_of.emmc<-dDIC_of.emmc[order(dDIC_of.emmc$Sub_region),]
  dDIC_of.emmc

Models summary

dDIC_models<-list("Inshore" = dDIC_in, 
                   "Mid channel" = dDIC_mc, 
                   "Offshore" = dDIC_of)
modelsummary(dDIC_models, stars = TRUE, 
             #statistic = c('std.error', 'p.value', 'conf.int'),
             title = 'dDIC model outputs',
             coef_map=factor_order)
dDIC model outputs
Inshore Mid channel Offshore
Year −1.084**
(0.414)
Intercept 10.259 3.351 2188.848**
(26.313) (11.248) (835.522)
Upper Keys −16.022 −9.260 −2.824
(17.754) (7.525) (2.373)
Middle Keys −44.964* −22.939*** −8.251***
(17.592) (6.690) (2.354)
Lower Keys −70.184*** −26.218*** −1.524
(17.548) (6.662) (2.225)
Num.Obs. 367 345 421
R2 Marg. 0.061 0.034 0.051
R2 Cond. 0.609 0.410 0.161
AIC 4163.9 3596.6 3505.7
BIC 4191.3 3619.6 3534.0
ICC 0.6 0.4 0.1
RMSE 65.35 42.22 15.00
+ p
#modelsummary(dDIC_models, estimate = "p.value")

7. PCA

#str(Month_Stats)
PCA_variables<-c("DIC_mean", "TA_mean", "pCO2_mean", "Ara_mean",
              "pH_mean", "Tem_mean","Sal_mean", "Season",
              "Zone", "Sub_region", "Month2")

PCA.data<-select(Month_Stats, PCA_variables)

Name<-paste(Month_Stats$Zone, Month_Stats$Sub_region, 
            Month_Stats$Month, sep = "_")
rownames(PCA.data) <- (Name)
PCA_var.names<-c("DIC", "TA", "pCO2", "Ara",
              "pH", "Temp","Sal", "Season",
              "Zone", "Sub_region", "Month")
colnames(PCA.data) <- (PCA_var.names)
#ggpairs(PCA.data)
head(PCA.data)
library(vegan)
#library(autoplot)
library(ggfortify)

CC.rda1 <- rda(PCA.data[, -(6:11)], scale=TRUE)
CC.rda2 <- prcomp(PCA.data[, -(6:11)], scale=TRUE)
summary(CC.rda1)
## 
## Call:
## rda(X = PCA.data[, -(6:11)], scale = TRUE) 
## 
## Partitioning of correlations:
##               Inertia Proportion
## Total               5          1
## Unconstrained       5          1
## 
## Eigenvalues, and their contribution to the correlations 
## 
## Importance of components:
##                          PC1    PC2     PC3      PC4       PC5
## Eigenvalue            2.5944 1.9403 0.45711 0.006922 0.0012585
## Proportion Explained  0.5189 0.3881 0.09142 0.001384 0.0002517
## Cumulative Proportion 0.5189 0.9069 0.99836 0.999748 1.0000000
## 
## Scaling 2 for species and site scores
## * Species are scaled proportional to eigenvalues
## * Sites are unscaled: weighted dispersion equal on all dimensions
## * General scaling constant of scores:  5.469602 
## 
## 
## Species scores
## 
##          PC1     PC2      PC3       PC4       PC5
## DIC  -1.1029  2.1822 -0.03542 -0.008113 -0.061935
## TA    0.1238  2.3756 -0.56714 -0.010744  0.054366
## pCO2 -2.3089 -0.5250 -0.59657  0.143727  0.005462
## Ara   2.0089 -0.4769 -1.31126  0.002960 -0.026257
## pH    2.2192  0.8374  0.58039  0.143427 -0.004362
## 
## 
## Site scores (weighted sums of species scores)
## 
##                          PC1       PC2       PC3        PC4       PC5
## Inshore_BB_Jan     -0.272379  0.691922  0.464656 -0.1099471 -0.158317
## Inshore_BB_Feb      0.272418  0.600475  0.320829  0.2191620 -0.312778
## Inshore_BB_Mar      0.380946  0.511217 -0.015298  0.2823851 -0.093517
## Inshore_BB_Apr      0.850344 -0.237717  0.026057  0.5966009  0.177635
## Inshore_BB_May      0.746874 -0.136414 -0.216369  0.4658404  0.011938
## Inshore_BB_Jun      0.285798 -0.908645  0.524958 -0.4155568 -0.166686
## Inshore_BB_Jul     -0.444217 -0.487107 -0.212568  0.0041688  0.543124
## Inshore_BB_Aug     -0.341170 -0.441671 -0.452599  0.5537129  0.216457
## Inshore_BB_Sep     -1.174026  0.032383 -0.193326  1.8622707  0.206118
## Inshore_BB_Oct     -1.171340  0.216051 -0.264913  1.5234470  0.218991
## Inshore_BB_Nov     -0.675844  0.449297  0.192224  0.1885164  0.187854
## Inshore_BB_Dec     -0.271227  0.561826  0.388899 -0.1141498 -0.183539
## Inshore_UK_Jan     -0.131216  0.919059  0.319806  0.1006433 -0.053077
## Inshore_UK_Feb      0.609058  0.398344  0.279700  0.6700555 -0.251988
## Inshore_UK_Mar      0.537766  0.402503 -0.069266  0.4029285  0.358694
## Inshore_UK_Apr      1.481157 -0.591785 -0.175134  1.9849146  0.310744
## Inshore_UK_May      1.232421 -0.526323 -0.203991  1.1017521  0.419967
## Inshore_UK_Jun      0.469914 -0.414224 -0.176666 -0.2824107  0.015573
## Inshore_UK_Jul     -0.074839 -0.383048 -0.468384 -0.2350545  0.080163
## Inshore_UK_Aug      0.286982 -0.328415 -0.829756 -0.3915844  0.014936
## Inshore_UK_Sep     -0.920822 -0.373659 -0.325180  1.2251027  0.113247
## Inshore_UK_Oct     -1.060306  0.036598 -0.213666  1.4718463  0.153896
## Inshore_UK_Nov     -1.069601  0.699378 -0.042354  1.0301854  0.893107
## Inshore_UK_Dec     -0.387882  0.851172  0.114440  0.0368029  0.310689
## Inshore_MK_Jan     -0.315480  0.895362  0.258144 -0.0705074  0.183153
## Inshore_MK_Feb      0.619871  0.786041 -0.062712  1.0056499 -1.178989
## Inshore_MK_Mar      0.411287  0.414342 -0.087735  0.1827799  0.491210
## Inshore_MK_Apr      1.108327 -0.317746 -0.149535  1.1268399  0.356214
## Inshore_MK_May      1.223427 -0.659784 -0.064130  1.1703070  0.533580
## Inshore_MK_Jun      0.523935 -1.035346  0.329953 -0.1140607 -0.001052
## Inshore_MK_Jul     -0.289009 -1.216137  0.439818 -0.4096161  0.460619
## Inshore_MK_Aug      0.036473 -1.074496  0.338568 -0.6610479  0.093846
## Inshore_MK_Sep     -0.648288 -0.773930  0.280517  0.1338367  0.442284
## Inshore_MK_Oct     -0.498062 -0.146284 -0.033121  0.5370888 -0.643452
## Inshore_MK_Nov     -0.498429  0.117859  0.347102 -0.0729214  0.301566
## Inshore_MK_Dec     -0.287707  0.806998  0.221431  0.0081968 -0.031416
## Inshore_LK_Jan     -0.656640  0.312186  1.046642 -0.1405027  0.309660
## Inshore_LK_Feb      0.110192  0.621121  0.353034  0.1523841 -0.518591
## Inshore_LK_Mar      0.426923  0.191538  0.228841  0.3705963  0.146184
## Inshore_LK_Apr      0.626584 -0.649475  0.585984  0.2895094 -0.349235
## Inshore_LK_May      0.631593 -1.217018  1.155171 -0.0273152 -0.023007
## Inshore_LK_Jun      0.060518 -1.083452  0.681062 -0.3814186  0.181271
## Inshore_LK_Jul     -0.720779 -1.255383  0.707658  0.1131456  0.122450
## Inshore_LK_Aug     -0.576415 -1.582907  0.963565  0.2283386 -2.100300
## Inshore_LK_Sep     -0.801218 -0.872523  0.505717  0.4680002  0.132707
## Inshore_LK_Oct     -0.739680 -0.744149  0.793617  0.3529505 -0.258240
## Inshore_LK_Nov     -0.963632 -0.033628  0.524101  0.2763751  0.958829
## Inshore_LK_Dec     -0.304766 -0.015814  1.069776 -0.2795579 -0.210587
## Mid channel_BB_Jan  0.027816  0.271188  0.420160 -0.2164743 -0.005563
## Mid channel_BB_Feb  0.107344  0.316050  0.495185 -0.1044365 -0.188670
## Mid channel_BB_Mar  0.247549  0.288581  0.243455 -0.0943901  0.187354
## Mid channel_BB_Apr  0.373367  0.052513  0.069195 -0.0471094  0.157799
## Mid channel_BB_May  0.324871  0.152536 -0.171991 -0.1565114  0.170819
## Mid channel_BB_Jun  0.122118 -0.182032 -0.150988 -0.3165015 -0.201615
## Mid channel_BB_Jul -0.261711 -0.103029 -0.512555 -0.0906459  0.180654
## Mid channel_BB_Aug -0.162639 -0.232497 -0.556464 -0.2932580  0.252667
## Mid channel_BB_Sep -0.650792 -0.038128 -0.201716  0.4754130 -0.186922
## Mid channel_BB_Oct -0.329703  0.019930 -0.273383  0.0253423 -0.319908
## Mid channel_BB_Nov -0.362413  0.189511  0.020472  0.0035264  0.364634
## Mid channel_BB_Dec -0.080520  0.330699  0.293850 -0.2116488  0.004395
## Mid channel_UK_Jan  0.139588  0.395990  0.319130 -0.0676589 -0.137564
## Mid channel_UK_Feb  0.309461  0.267720  0.503656  0.1372748 -0.405322
## Mid channel_UK_Mar  0.444319  0.142571  0.206860  0.1918618  0.108416
## Mid channel_UK_Apr  0.635788  0.045489 -0.191015  0.3748800  0.123618
## Mid channel_UK_May  0.705328  0.108866 -0.431302  0.4232428  0.343377
## Mid channel_UK_Jun  0.178812 -0.050278 -0.426803 -0.3229466  0.140829
## Mid channel_UK_Jul -0.163013 -0.186142 -0.540347 -0.1661891 -0.110097
## Mid channel_UK_Aug  0.142560  0.050587 -0.976053 -0.3617340  0.126345
## Mid channel_UK_Sep -0.488549 -0.090577 -0.484462  0.5766830 -0.247703
## Mid channel_UK_Oct -0.301796 -0.016799 -0.336452  0.0565071 -0.543577
## Mid channel_UK_Nov -0.477884  0.092964  0.211991  0.0475302  0.121392
## Mid channel_UK_Dec -0.027189  0.336005  0.265682 -0.2273655  0.092068
## Mid channel_MK_Jan -0.132939  0.597376  0.197684 -0.1568954  0.201887
## Mid channel_MK_Feb  0.315885  0.335899  0.408721  0.1592351 -0.339990
## Mid channel_MK_Mar  0.396814  0.316764  0.122129  0.2429641  0.310896
## Mid channel_MK_Apr  0.617345  0.087571 -0.212291  0.2010248  0.213396
## Mid channel_MK_May  0.717589 -0.263968 -0.140637  0.3503768  0.317073
## Mid channel_MK_Jun  0.237239 -0.595405  0.037210 -0.4174343 -0.051692
## Mid channel_MK_Jul -0.216268 -0.675125 -0.100763 -0.3147962  0.034242
## Mid channel_MK_Aug  0.152739 -0.452837 -0.440989 -0.4937739 -0.071266
## Mid channel_MK_Sep -0.413916 -0.467108 -0.045401 -0.0595721 -0.253919
## Mid channel_MK_Oct -0.132252  0.011830 -0.368464 -0.0580431 -0.603035
## Mid channel_MK_Nov -0.294367  0.076062  0.165701 -0.1151497  0.080504
## Mid channel_MK_Dec -0.128313  0.433207  0.310124 -0.1271917  0.018153
## Mid channel_LK_Jan -0.441394  0.304326  0.742244 -0.1426029 -0.028110
## Mid channel_LK_Feb  0.147012  0.576346  0.269111  0.1143538 -0.246307
## Mid channel_LK_Mar  0.162114  0.310472  0.182092 -0.0899937  0.085535
## Mid channel_LK_Apr  0.220247 -0.118015  0.157447  0.2557912  0.138649
## Mid channel_LK_May  0.443824 -0.630229  0.631471 -0.2024468  0.125221
## Mid channel_LK_Jun  0.064426 -0.356803 -0.013168 -0.3739680  0.132184
## Mid channel_LK_Jul -0.322013 -0.500906 -0.200915 -0.1430501  0.045734
## Mid channel_LK_Aug -0.139133 -0.719313  0.021488 -0.4455852  2.596236
## Mid channel_LK_Sep -0.403774 -0.514397  0.050025 -0.0608102 -0.369386
## Mid channel_LK_Oct -0.209240 -0.124067 -0.189483 -0.1195314 -0.447048
## Mid channel_LK_Nov -0.397931  0.038183  0.112575 -0.0435787  0.316707
## Mid channel_LK_Dec -0.011135  0.181993  0.402097 -0.2073895 -0.048307
## Offshore_BB_Jan     0.094639  0.202050  0.257713 -0.1616951 -0.250127
## Offshore_BB_Feb     0.246880  0.187418  0.517195 -0.0002223 -0.277095
## Offshore_BB_Mar     0.247177  0.232596  0.244117 -0.1080296  0.195279
## Offshore_BB_Apr     0.061421  0.170950  0.087916 -0.2697911  0.222204
## Offshore_BB_May     0.177506  0.158261 -0.098723 -0.2101719  0.034345
## Offshore_BB_Jun    -0.117707 -0.011749 -0.233372 -0.2549729  0.197366
## Offshore_BB_Jul    -0.149370 -0.057170 -0.558836 -0.1281561 -0.187325
## Offshore_BB_Aug    -0.306713 -0.185217 -0.517237 -0.1358155  0.405680
## Offshore_BB_Sep    -0.241875 -0.017887 -0.547435  0.1705399 -0.558985
## Offshore_BB_Oct    -0.041980 -0.035943 -0.373132 -0.1447452 -0.624485
## Offshore_BB_Nov    -0.163689  0.140543 -0.128061 -0.1006554  0.318614
## Offshore_BB_Dec     0.020843  0.197247  0.195626 -0.1968915 -0.018085
## Offshore_UK_Jan     0.117996  0.224795  0.268254 -0.2017194  0.013086
## Offshore_UK_Feb     0.206530  0.262528  0.584675  0.0365769 -0.428452
## Offshore_UK_Mar     0.203353  0.227080  0.217806 -0.1751998  0.203339
## Offshore_UK_Apr     0.087257  0.156344  0.106252 -0.2353006  0.157848
## Offshore_UK_May     0.123547  0.199670 -0.148077 -0.2726268  0.305191
## Offshore_UK_Jun    -0.020314 -0.010433 -0.298227 -0.3324183  0.241518
## Offshore_UK_Jul    -0.182954 -0.159520 -0.511902 -0.1373704 -0.085680
## Offshore_UK_Aug     0.073760  0.014392 -0.857112 -0.3624673  0.182729
## Offshore_UK_Sep    -0.131902 -0.077189 -0.625520 -0.0453484 -0.488111
## Offshore_UK_Oct     0.049137 -0.006270 -0.393591 -0.1610509 -0.690637
## Offshore_UK_Nov    -0.328974  0.029951  0.016280 -0.0272213  0.214979
## Offshore_UK_Dec    -0.011484  0.253316  0.159294 -0.2167585  0.090499
## Offshore_MK_Jan     0.020292  0.239692  0.311475 -0.2483381  0.039121
## Offshore_MK_Feb     0.212486  0.287005  0.640178  0.0711030 -0.461947
## Offshore_MK_Mar     0.167949  0.245177  0.227452 -0.1946883  0.249919
## Offshore_MK_Apr     0.211927  0.144859  0.051341 -0.1827855  0.169375
## Offshore_MK_May     0.117455  0.136568 -0.106852 -0.2508365  0.280804
## Offshore_MK_Jun     0.174030 -0.137077 -0.237590 -0.3399719  0.012379
## Offshore_MK_Jul    -0.176367 -0.311803 -0.328304 -0.1615133 -0.245292
## Offshore_MK_Aug     0.083749 -0.083170 -0.711071 -0.3574560  0.004723
## Offshore_MK_Sep    -0.142458 -0.183522 -0.396511 -0.1274628 -0.477251
## Offshore_MK_Oct     0.017719  0.002412 -0.429455 -0.1287964 -0.712757
## Offshore_MK_Nov    -0.125116  0.084615 -0.123884 -0.0657433  0.150421
## Offshore_MK_Dec     0.070349  0.163956  0.250276 -0.1637809 -0.112147
## Offshore_LK_Jan     0.002444  0.279240  0.414633 -0.2451106  0.061644
## Offshore_LK_Feb     0.103299  0.310233  0.718745  0.0250108 -0.482889
## Offshore_LK_Mar     0.141527  0.168049  0.183831 -0.2263034  0.273595
## Offshore_LK_Apr    -0.026695  0.078487  0.196372 -0.2320677  0.277058
## Offshore_LK_May     0.023278  0.092947  0.082945 -0.3535737  0.340662
## Offshore_LK_Jun    -0.040452 -0.054511 -0.233011 -0.3527097  0.230755
## Offshore_LK_Jul    -0.366320 -0.130999 -0.445877  0.0485103  0.132517
## Offshore_LK_Aug    -0.135899 -0.047940 -0.614103 -0.2489012  0.404367
## Offshore_LK_Sep    -0.187357 -0.112903 -0.365389 -0.0319935 -0.528833
## Offshore_LK_Oct    -0.054760 -0.017707 -0.314172 -0.1962809 -0.415250
## Offshore_LK_Nov    -0.261344  0.084855 -0.046039 -0.0607739  0.355848
## Offshore_LK_Dec     0.105968  0.162302  0.204457 -0.1056861 -0.219242
## Oceanic_UK_Jan      0.116386  0.145657  0.147585 -0.2276401 -0.062608
## Oceanic_UK_Feb      0.224225  0.265908  0.575611  0.0207100 -0.216071
## Oceanic_UK_Mar      0.210853  0.108698  0.272847 -0.1727647  0.001050
## Oceanic_UK_Apr      0.230648  0.146471  0.181060 -0.1283766 -0.064051
## Oceanic_UK_May      0.285901  0.216495 -0.149354 -0.2047512  0.304087
## Oceanic_UK_Jun      0.110768  0.056801 -0.386743 -0.3233744  0.177900
## Oceanic_UK_Jul     -0.094032 -0.134068 -0.536872 -0.0335767 -0.710588
## Oceanic_UK_Aug      0.122940  0.184028 -0.977464 -0.3513756  0.322607
## Oceanic_UK_Sep     -0.005012 -0.057522 -0.620110 -0.0254629 -0.874835
## Oceanic_UK_Oct     -0.001904 -0.038419 -0.454190 -0.1528981 -0.607495
## Oceanic_UK_Nov     -0.362185  0.084373 -0.037581  0.0726912  0.074331
## Oceanic_UK_Dec      0.093812  0.211356  0.061470 -0.1905821  0.120498
## Oceanic_MK_Jan      0.103012  0.207417  0.251834 -0.2071099 -0.029856
## Oceanic_MK_Feb      0.290080  0.216463  0.475611  0.0578686 -0.298683
## Oceanic_MK_Mar      0.124129  0.125321  0.176655 -0.2767160  0.179863
## Oceanic_MK_Apr      0.009943  0.148176  0.084632 -0.2743630  0.286291
## Oceanic_MK_May      0.013544  0.201969 -0.107842 -0.2742015  0.293429
## Oceanic_MK_Jun      0.085494  0.036501 -0.392986 -0.3361585  0.260028
## Oceanic_MK_Jul     -0.119019 -0.099287 -0.539476 -0.1003937 -0.336104
## Oceanic_MK_Aug      0.036292  0.043633 -0.779012 -0.2959192 -0.015420
## Oceanic_MK_Sep     -0.028008  0.021147 -0.646887 -0.0757960 -0.497093
## Oceanic_MK_Oct     -0.006473  0.041053 -0.522417 -0.1677384 -0.407504
## Oceanic_MK_Nov      0.015388  0.086324 -0.206021 -0.1855881  0.289422
## Oceanic_MK_Dec      0.064452  0.127672  0.230045 -0.1757171 -0.118489
## Oceanic_LK_Jan      0.075786  0.228659  0.316479 -0.2422946  0.120143
## Oceanic_LK_Feb      0.259839  0.295997  0.515907  0.0707476 -0.198802
## Oceanic_LK_Mar      0.146556  0.103057  0.140167 -0.2564721  0.142702
## Oceanic_LK_Apr     -0.014314  0.100364  0.150169 -0.2946073  0.169104
## Oceanic_LK_May      0.020027  0.170524 -0.008745 -0.3283284  0.312733
## Oceanic_LK_Jun      0.036178  0.048539 -0.355358 -0.3119397  0.238326
## Oceanic_LK_Jul     -0.228284 -0.062666 -0.498783 -0.0218039 -0.305378
## Oceanic_LK_Aug     -0.048204  0.022345 -0.713934 -0.2451638 -0.365497
## Oceanic_LK_Sep      0.009807 -0.026111 -0.588335 -0.0117892 -0.735383
## Oceanic_LK_Oct     -0.005716 -0.008146 -0.405671 -0.1939036 -0.481968
## Oceanic_LK_Nov     -0.147811  0.123518 -0.185444 -0.0305197  0.213744
## Oceanic_LK_Dec      0.103015  0.139055  0.140125 -0.1210380 -0.278429
# Checking if the PC axes are meaningful
eigenval <- CC.rda1$CA$eig   # Here you will get the eigenvalues
sitecoord <- CC.rda1$CA$u[,1:2]   # The site coordinates along PC1 and PC2
  eig <- data.frame(eigenval)
  eig$nb <- c(1:length(eigenval))
  eig$prop <- eig$eigenval/sum(eig$eigenval)
  eig
# (Kaiser-Guttman)
par(mfrow=c(1,2))
  barplot(eig$eigenval, main="Eigenvalues",las=2)
  abline(h=mean(eig$eigenval),col="red")    # average eigenvalue
  legend("topright","Average eigenvalue",lwd=1,col=2,bty="n")
  
  barplot(100*eig$prop,main="% of variance",las=2)

par(mfrow=c(1,1))

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Zone)+MyTheme+Season_colour+Season_fill

autoplot(CC.rda2, data = PCA.data, colour="Zone", 
                shape="Sub_region",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Sub_region", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_grid(~Season)+MyTheme

autoplot(CC.rda2, data = PCA.data, colour="Season", 
                shape="Zone",
         loadings = TRUE, loadings.colour = 'black',
         loadings.label = TRUE, loadings.label.size = 3,
         loadings.label.vjust = -1.0,
         loadings.label.colour="black",
         frame = TRUE, frame.type = 'norm')+
facet_wrap(~Sub_region)+MyTheme+Season_colour+Season_fill

Packages used

# Creates bibliography 
#knitr::write_bib(c(.packages()), "packages.bib")
Arel-Bundock, Vincent. 2022. Modelsummary: Summary Tables and Plots for Statistical Models and Data: Beautiful, Customizable, and Publication-Ready. https://vincentarelbundock.github.io/modelsummary/.
Arnold, Jeffrey B. 2021. Ggthemes: Extra Themes, Scales and Geoms for Ggplot2. https://github.com/jrnold/ggthemes.
Attali, Dean, and Christopher Baker. 2019. ggExtra: Add Marginal Histograms to Ggplot2, and More Ggplot2 Enhancements. https://github.com/daattali/ggExtra.
Auguie, Baptiste. 2017. gridExtra: Miscellaneous Functions for "Grid" Graphics. https://CRAN.R-project.org/package=gridExtra.
Bates, Douglas, Martin Mächler, Ben Bolker, and Steve Walker. 2015. “Fitting Linear Mixed-Effects Models Using lme4.” Journal of Statistical Software 67 (1): 1–48. https://doi.org/10.18637/jss.v067.i01.
Bates, Douglas, and Martin Maechler. 2021. Matrix: Sparse and Dense Matrix Classes and Methods. http://Matrix.R-forge.R-project.org/.
Bates, Douglas, Martin Maechler, Ben Bolker, and Steven Walker. 2021. Lme4: Linear Mixed-Effects Models Using Eigen and S4. https://github.com/lme4/lme4/.
Cheng, Joe, Bhaskar Karambelkar, and Yihui Xie. 2021. Leaflet: Create Interactive Web Maps with the JavaScript Leaflet Library. https://rstudio.github.io/leaflet/.
Grolemund, Garrett, and Hadley Wickham. 2011. “Dates and Times Made Easy with lubridate.” Journal of Statistical Software 40 (3): 1–25. https://www.jstatsoft.org/v40/i03/.
Henry, Lionel, and Hadley Wickham. 2020. Purrr: Functional Programming Tools. https://CRAN.R-project.org/package=purrr.
J, Lemon. 2006. “Plotrix: A Package in the Red Light District of r.” R-News 6 (4): 8–12.
Kassambara, Alboukadel. 2020. Ggpubr: Ggplot2 Based Publication Ready Plots. https://rpkgs.datanovia.com/ggpubr/.
Kuznetsova, Alexandra, Per B. Brockhoff, and Rune H. B. Christensen. 2017. lmerTest Package: Tests in Linear Mixed Effects Models.” Journal of Statistical Software 82 (13): 1–26. https://doi.org/10.18637/jss.v082.i13.
Kuznetsova, Alexandra, Per Bruun Brockhoff, and Rune Haubo Bojesen Christensen. 2019. lmerTest: Tests in Linear Mixed Effects Models. https://github.com/runehaubo/lmerTestR.
Legendre, Pierre. 2018. Lmodel2: Model II Regression. https://CRAN.R-project.org/package=lmodel2.
Lemon, Jim, Ben Bolker, Sander Oom, Eduardo Klein, Barry Rowlingson, Hadley Wickham, Anupam Tyagi, et al. 2021. Plotrix: Various Plotting Functions. https://CRAN.R-project.org/package=plotrix.
Lenth, Russell V. 2022. Emmeans: Estimated Marginal Means, Aka Least-Squares Means. https://github.com/rvlenth/emmeans.
Müller, Kirill, and Hadley Wickham. 2021. Tibble: Simple Data Frames. https://CRAN.R-project.org/package=tibble.
R Core Team. 2020. R: A Language and Environment for Statistical Computing. Vienna, Austria: R Foundation for Statistical Computing. https://www.R-project.org/.
Robinson, David, Alex Hayes, and Simon Couch. 2022. Broom: Convert Statistical Objects into Tidy Tibbles. https://CRAN.R-project.org/package=broom.
Spinu, Vitalie, Garrett Grolemund, and Hadley Wickham. 2021. Lubridate: Make Dealing with Dates a Little Easier. https://CRAN.R-project.org/package=lubridate.
Wickham, Hadley. 2007. “Reshaping Data with the reshape Package.” Journal of Statistical Software 21 (12): 1–20. http://www.jstatsoft.org/v21/i12/.
———. 2011. “The Split-Apply-Combine Strategy for Data Analysis.” Journal of Statistical Software 40 (1): 1–29. http://www.jstatsoft.org/v40/i01/.
———. 2016. Ggplot2: Elegant Graphics for Data Analysis. Springer-Verlag New York. https://ggplot2.tidyverse.org.
———. 2019. Stringr: Simple, Consistent Wrappers for Common String Operations. https://CRAN.R-project.org/package=stringr.
———. 2020a. Plyr: Tools for Splitting, Applying and Combining Data. https://CRAN.R-project.org/package=plyr.
———. 2020b. Reshape2: Flexibly Reshape Data: A Reboot of the Reshape Package. https://github.com/hadley/reshape.
———. 2021a. Forcats: Tools for Working with Categorical Variables (Factors). https://CRAN.R-project.org/package=forcats.
———. 2021b. Tidyr: Tidy Messy Data. https://CRAN.R-project.org/package=tidyr.
———. 2021c. Tidyverse: Easily Install and Load the Tidyverse. https://CRAN.R-project.org/package=tidyverse.
Wickham, Hadley, Mara Averick, Jennifer Bryan, Winston Chang, Lucy D’Agostino McGowan, Romain François, Garrett Grolemund, et al. 2019. “Welcome to the tidyverse.” Journal of Open Source Software 4 (43): 1686. https://doi.org/10.21105/joss.01686.
Wickham, Hadley, Winston Chang, Lionel Henry, Thomas Lin Pedersen, Kohske Takahashi, Claus Wilke, Kara Woo, Hiroaki Yutani, and Dewey Dunnington. 2021. Ggplot2: Create Elegant Data Visualisations Using the Grammar of Graphics. https://CRAN.R-project.org/package=ggplot2.
Wickham, Hadley, Romain François, Lionel Henry, and Kirill Müller. 2021. Dplyr: A Grammar of Data Manipulation. https://CRAN.R-project.org/package=dplyr.
Wickham, Hadley, and Jim Hester. 2020. Readr: Read Rectangular Text Data. https://CRAN.R-project.org/package=readr.
Xie, Yihui. 2014. “Knitr: A Comprehensive Tool for Reproducible Research in R.” In Implementing Reproducible Computational Research, edited by Victoria Stodden, Friedrich Leisch, and Roger D. Peng. Chapman; Hall/CRC. http://www.crcpress.com/product/isbn/9781466561595.
———. 2015. Dynamic Documents with R and Knitr. 2nd ed. Boca Raton, Florida: Chapman; Hall/CRC. https://yihui.org/knitr/.
———. 2021. Knitr: A General-Purpose Package for Dynamic Report Generation in r. https://yihui.org/knitr/.
Zhu, Hao. 2021. kableExtra: Construct Complex Table with Kable and Pipe Syntax. https://CRAN.R-project.org/package=kableExtra.